mread failed but mcode worked

22 views
Skip to first unread message

yami...@gmail.com

unread,
Jul 9, 2016, 10:17:27 PM7/9/16
to mrgsolve
Hi group,

I managed to get mrgsolve installed on Windows PC, and "example("mrgsolve")" gave me the expected results.

  • R version: R version 3.3.1 (2016-06-21)
  • mrgsolve version: mrgsolve_0.6.1.9014

I got the below error message (only the beginning portion is pasted below) when attempting "mod <- mread("poppk", code)",  but "mod <- mcode("poppk", code)" worked fine.  Can someone tell me what's wrong in model code? 

Thanks 

Yaming Su
Modeling and Simulation
Daiichi Sankyo


##########################################
  • error message:
Error in normalizePath(path.expand(path), winslash, mustWork) : path[1]="
$PARAM TVVM = 8.346, TVKM = 1.093, TVVC = 2.091,
  • model code:
code <- '
$PARAM TVVM = 8.346, TVKM = 1.093, TVVC = 2.091, TVCLO = 0.2676, TVKA = 0.1309,
TVQ = 0.1544, TVVP = 6.189, WTCL = 0.7608, WTVM = 0.5495, ALBVM = -0.8595,
CLCRVM = 0.2199, C1P2F2KA = 0.6451, ADA1CLO = 1.359, C1P2F2CLO = 1.23,
SEXCLO = 0.8067, CRPVM = 0.02322

// covariates in below line are dummy number
WT = 1, ALBR = 1, CLCRN = 1, BLCRP = 1, ADA1 = 1, C1P2F2 = 1, SEX = 1

$CMT DEPOT CENT PERI

$OMEGA cor=TRUE
0.107 -0.606 0.310
$OMEGA 0.112
$OMEGA 0.128

$SIGMA 0.4005

$MAIN
double ETAVM = ETA(1);
double ETACLO = ETA(2);
double ETAVC = ETA(3);
double ETAKA = ETA(4);

double VM = TVVM *pow(WT/72, WTVM) *pow(ALBR/0.78, ALBVM) *pow(CLCRN/100, CLCRVM) *pow(BLCRP/14.6, CRPVM) *exp(ETAVM);
double KM = TVKM;
double VC = TVVC * exp(ETAVC);
double CLO = TVCLO *pow(WT/72, WTCL) *pow(ADA1CLO, ADA1) *pow(C1P2F2CLO, C1P2F2) *pow(SEXCLO, SEX)  * exp(ETACLO);
double KA = TVKA * pow(C1P2F2KA, C1P2F2)  *exp(ETAKA);
double Q = TVQ;
double VP = TVVP;

$ODE
double C2 = CENT/VC;
double C3 = PERI/VP;

dxdt_DEPOT = -KA*DEPOT;
dxdt_CENT = KA*DEPOT - Q*C2 + Q*C3 -CLO*C2 - VM*C2/(KM + C2);
dxdt_PERI = Q*C2 - Q*C3;

$TABLE
double DV = C2*exp(EPS(1));

$CAPTURE C2
'

Kyle Baron

unread,
Jul 10, 2016, 10:03:24 PM7/10/16
to mrgsolve, yami...@gmail.com
Hi Yaming - 


Check out the arguments for mcode and mread.  


> args(mread)
function (model = character(0), project = getwd(), code = NULL,
    udll
= TRUE, ignore.stdout = TRUE, raw = FALSE, compile = TRUE,
    audit
= FALSE, quiet = getOption("mrgsolve_mread_quiet",
        FALSE
), check.bounds = FALSE, warn = TRUE, soloc = tempdir(),
    preclean
= FALSE, ...)






> mcode
function (model, code, project = tempdir(), ...)
{
    mread
(model = model, project = project, code = code, ...)
}
<environment: namespace:mrgsolve>


The second argument for mread is the project directory and the second argument to mcode is the string with your model code.  Also, note that mcode is just a wrapper for mread. 


When you code the model in an R string (as you are doing), use mcode:

mod <- mcode("model_name", model_code)


To accomplish the same thing with mread it would be

mod <- mread("model_name", code=model_code, project=tempdir())


I prefer the mcode function for convenience in the arguments ... the order as well as offering tempdir() as the default project directory.


When you code the model in a separate .cpp file, you must use mread:
mod <- mread("model_name", "project_dir")



Hope this helps.  Please let me know if something is still confusing or not behaving the way you expect.

Best Regards,
Kyle

yami...@gmail.com

unread,
Jul 11, 2016, 10:14:12 AM7/11/16
to mrgsolve, yami...@gmail.com
Kyle,

Thanks for sparing time to answer my question.

I have a follow up question which deviates a little from the original question. Nevertheless, here it is. Once the model is compiled, I did a quick simulation with the below code:

out <-
  mod %>%
  drop.re %>%
  ev(amt = 200, addl = 12, ii = 14) %>%
  param(WT = 72, ALBR = 0.78, CLCRN = 100, BLCRP = 14.6,
        ADA1 = 0, C1P2F2 = 0, SEX = 1) %>%
  req(C2) %>%
  mrgsim(end= 172, delta=1)


plot(out)


It turned out that no plots were created but the below message popped up in R console:
No variables to plot


However, the above R code gave me the plot of C2 versus time in other platform (e.g., Metworx). I wonder if it is due to R version difference.  Information of R and mrgsolve versions in my Windows PC was posted in the original message.

I could still use plot(out, C2~.) to get the plot of C2 versus time,  but just don't understand why "plot(out)" failed.

Regards,
Yaming

Kyle Baron

unread,
Jul 11, 2016, 11:06:52 AM7/11/16
to mrgsolve, yami...@gmail.com
Hi Yaming - 

I think this is a but introduced when we (recently) switched to a new $CAPTURE mechanism (https://github.com/mrgsolve/examples/blob/master/misc_demo/capture.md).  I'm going to get something in the issue tracker (https://github.com/metrumresearchgroup/mrgsolve/issues) and hopefully get a fix issued.

Kyle

Kyle Baron

unread,
Jul 11, 2016, 11:19:07 AM7/11/16
to mrgsolve, yami...@gmail.com

This is (was) a bug.  https://github.com/metrumresearchgroup/mrgsolve/issues/71  I bumped the version number when committing (0.6.1.9015). This should fix the bug.  Thanks for reporting.  

Kyle





On Monday, July 11, 2016 at 10:06:52 AM UTC-5, Kyle Baron wrote:
Hi Yaming - 

Reply all
Reply to author
Forward
0 new messages