Closed braemd closed 2 years ago
Hi @braemd,
I'm unsure if it is ggPMX or nlmixr. You can see by trying something like:
library(ggplot2)
library(nlmixr)
library(ggPMX)
one.cmt <- function() {
ini({
## You may label each parameter with a comment
tka <- 0.45 # Log Ka
tcl <- log(c(0, 2.7, 100)) # Log Cl
## This works with interactive models
## You may also label the preceding line with label("label text")
tv <- 3.45; label("log V")
## the label("Label name") works with all models
eta.ka ~ 0.6
eta.cl ~ 0.3
eta.v ~ 0.1
add.sd <- 0.7
})
model({
ka <- exp(tka + eta.ka)
cl <- exp(tcl + eta.cl)
v <- exp(tv + eta.v)
linCmt() ~ add(add.sd)
})
}
fit <- nlmixr(one.cmt, theo_sd, est="saem", list(print=0))
addNpde(fit)
nlmixr::vpc(fit)
If one of these seem to be problematic you can say the problem is with nlmixr; Otherwise it is with ggPMX.
Note that the data section in the ggPMX controller is missing for nlmixr since it doesn't actually read data files to produce the controller like NONMEM and Monolix, so this information is not in the nlmixr style controller
Thanks, in the example without ggPMX, everything worked and I could create the vpc plot using nlmixr::vpc(fit). So it seems to be related to ggPMX.?
And thanks for clarifying the lack of the data section, makes sense.
It may be. Perhaps you can submit the code so that we can check what is going on here?
Thanks for reporting the issue.
@mattfidler
I also have a similar problem. Interestingly, If I used the function “theophylline()” for quick reference, it is OK. I can see an excellent vpc plot. ctr <- theophylline()
However, if I test using the sample code listed in ggPMX-guide.pdf, I can see only “NULL” output.
I used nlmixr version = 2.0.6 ggPMX=1.2.4 R version = 4.1.2 Rstudio = 2021.09.1
YJ
library(RxODE)
library(nlmixr)
library(ggPMX)
one.cmt <- function() {
ini({
## You may label each parameter with a comment
tka <- 0.45 # Log Ka
tcl <- 1 # Log Cl
## This works with interactive models
## You may also label the preceding line with label("label text")
tv <- 3.45; label("log V")
## the label("Label name") works with all models
eta.ka ~ 0.6
eta.cl ~ 0.3
eta.v ~ 0.1
add.sd <- 0.7
})
model({
ka <- exp(tka + eta.ka)
cl <- exp(tcl + eta.cl)
v <- exp(tv + eta.v)
linCmt() ~ add(add.sd)
})
}
fit <- nlmixr(one.cmt, theo_sd, est="saem", control=list(print=0))
## The fit object is a nlmixr fit; You can read it into the nlmixr controller by:
ctr <- pmx_nlmixr(fit)
ctr %>% pmx_plot_vpc()
> library(RxODE)
RxODE 1.1.2 using 4 threads (see ?getRxThreads)
no cache: create with `rxCreateCache()`
> library(nlmixr)
> library(ggPMX)
Registered S3 method overwritten by 'GGally':
method from
+.gg ggplot2
>
> one.cmt <- function() {
+ ini({
+ ## You may label each parameter with a comment
+ tka <- 0.45 # Log Ka
+ tcl <- 1 # Log Cl
+ ## This works with interactive models
+ ## You may also label the preceding line with label("label text")
+ tv <- 3.45; label("log V")
+ ## the label("Label name") works with all models
+ eta.ka ~ 0.6
+ eta.cl ~ 0.3
+ eta.v ~ 0.1
+ add.sd <- 0.7
+ })
+ model({
+ ka <- exp(tka + eta.ka)
+ cl <- exp(tcl + eta.cl)
+ v <- exp(tv + eta.v)
+ linCmt() ~ add(add.sd)
+ })
+ }
> fit <- nlmixr(one.cmt, theo_sd, est="saem", control=list(print=0))
i parameter labels from comments will be replaced by 'label()'
> generate SAEM model
√ done
Calculating covariance matrix
[====|====|====|====|====|====|====|====|====|====] 0:00:00
> creating full model...
> pruning branches (`if`/`else`)...
√ done
> loading into symengine environment...
√ done
> compiling EBE model...
√ done
Calculating residuals/tables
done
> ## The fit object is a nlmixr fit; You can read it into the nlmixr controller by:
> ctr <- pmx_nlmixr(fit)
add npde
Compiling NPDE model...done
done
Compiling model...rx_5b58d2719a7cc24ad8f4f3b24f728965_x64.c: In function 'rx_5b58d2719a7cc24ad8f4f3b24f728965_x64_Rate':
rx_5b58d2719a7cc24ad8f4f3b24f728965_x64.c:611:7: warning: 'rx_pred_' is used uninitialized in this function [-Wuninitialized]
pred=rx_pred_;
~~~~^~~~~~~~~
done
Compiling VPC model...done
done (2.24 sec)
>
> ctr %>% pmx_plot_vpc()
NULL
>
>
> ```
Error: attempt to use zero-length variable name
>
Of course, the nlmixr VPC command works well using the fit data set.
nlmixr::vpc(fit,nsim=500)
Sorry It didn't see this. I think something happened with the nlmixr vpc in ggPMX
. I will look into it with nlmixr2
Thanks. I understood.
If vpc.ui can show a nice legend in VPC plots like ggPMX, many users will be satisfied with just using nlmixr. Are there any other tips? I mean the way to show a legend in VPC plots using vpc.ui.
I agree that the VPC has a nice legend with ggPMX
.
As for now, the legend would be a function of adding the proper arguments to the vpc function.
I am unsure why this broke in the first place, I need to add some tests on the ggPMX side so this doesn't break in the future. This shouldn't have an issue for testing in the future since nlmixr no longer requires python.
Thank you. @mattfidler
This has been fixed in the master branch of ggPMX
Hi,
I tried to reproduce the theophyllin example using nlmixr but I have some trouble creating a working controller. The "param" and the "plot" section in the controller are created correctly but the "data" section is missing. And when I want to plot e.g. a vpc, no plot appears and NULL is given as output.
There is a warning when compiling the model and I'm not sure whether this is related to ggPMX or rather to nlmixr itself. (I have not used nlmixr for a while)
But using the theophyllin()-function, I can create a controller correctly with "param", "data" and "plot" section.
I have following code and outputs:
Packages and platform
Do you see, where the error might be?
Many thanks in advance!