nlmixrdevelopment / nlmixr

nlmixr: an R package for population PKPD modeling
https://nlmixrdevelopment.github.io/nlmixr/
GNU General Public License v2.0
115 stars 45 forks source link

VPC does not show DV #116

Closed ryamy closed 5 years ago

ryamy commented 5 years ago

Hi mlmixr team, I started to use nlmixr few days ago and really impressed by your great work.

Now I have a trouble, vpc show nothing in vpc plots. When I turn on other switch as attached, it seems to be shown only pi and sim_median. How can I show full vpc plots?? Attached is my code and produced vpc_plots capture.

Thanks for your help.

log.txt log

mattfidler commented 5 years ago

Hi @ryamy ; This is a feature of the vpc package we rely on, who is documented in http://vpc.ronkeizer.com/

For me, this works just fine, but perhaps you can attach the full R script; This way I can figure out if this is a nlmixr issue or a vpc issue.

library(nlmixr)
one.cmt <- function() {
    ini({
        tka <- .5   # log Ka
        tcl <- -3.2 # log Cl
        tv <- -1    # log V
        eta.ka ~ 1
        eta.cl ~ 2
        eta.v ~ 1
        add.err <- 0.1
    })
    model({
        ka <- exp(tka + eta.ka)
        cl <- exp(tcl + eta.cl)
        v <- exp(tv + eta.v)
        linCmt() ~ add(add.err)
    })
}
fit <- nlmixr(one.cmt, theo_sd, est="saem", saemControl(print=100))
#> Compiling SAEM user function...
#> PKG_CXXFLAGS=-Ic:/R/NLMIXR~1.0-7/R/library/nlmixr/include -Ic:/R/NLMIXR~1.0-7/R/library/STANHE~1/include -Ic:/R/NLMIXR~1.0-7/R/library/Rcpp/include -Ic:/R/NLMIXR~1.0-7/R/library/RCPPAR~1/include -Ic:/R/NLMIXR~1.0-7/R/library/RCPPEI~1/include -Ic:/R/NLMIXR~1.0-7/R/library/BH/include
#> PKG_LIBS= $(BLAS_LIBS) $(LAPACK_LIBS)
#> done.
#> 1:    -3.5526   -0.6595    0.4192    1.9000    0.9500    0.9500   10.1848
#> 100:   -3.2374  -0.7642   0.4823   0.0728   0.0175   0.4242   0.4874
#> 200:   -3.2352  -0.7722   0.4458   0.0677   0.0176   0.3154   0.4795
#> 300:   -3.2107  -0.7875   0.4390   0.0710   0.0181   0.4081   0.4780
#> 400:   -3.2140  -0.7853   0.4468   0.0707   0.0178   0.4199   0.4782
#> 500:   -3.2156  -0.7836   0.4503   0.0696   0.0182   0.4188   0.4788
#> Calculating residuals/tables
#> done.

print(fit)
#> -- nlmixr SAEM(Solved); OBJF not calculated fit ---------------------------
#>       OBJF AIC BIC Log-likelihood Condition Number
#> SAEMg   NA  NA  NA             NA         20.20522
#> 
#> -- Time (sec; $time): -----------------------------------------------------
#>   saem setup optimize covariance table
#>  34.08 4.518        0          0  0.02
#> 
#> -- Population Parameters ($parFixed): -------------------------------------
#>         Parameter   Est.     SE %RSE Back-transformed(95%CI) BSV(CV%)
#> tka        log Ka   0.45  0.194   43       1.57 (1.07, 2.29)    72.1%
#> tcl        log Cl  -3.22 0.0816 2.54 0.0401 (0.0342, 0.0471)    26.9%
#> tv          log V -0.784 0.0435 5.56    0.457 (0.419, 0.497)    13.6%
#> add.err            0.692                               0.692         
#>         Shrink(SD)%
#> tka         -1.05% 
#> tcl          4.76% 
#> tv           9.94% 
#> add.err             
#> 
#>   Covariance Type ($covMethod): fim
#>   No correlations in between subject variability (BSV) matrix
#>   Full BSV covariance ($omega) or correlation ($omegaR; diagonals=SDs)
#>   Distribution stats (mean/skewness/kurtosis/p-value) available in $shrink
#> 
#> -- Fit Data (object is a modified tibble): --------------------------------
#> # A tibble: 132 x 18
#>   ID     TIME    DV  PRED    RES IPRED   IRES  IWRES eta.ka eta.cl  eta.v
#> * <fct> <dbl> <dbl> <dbl>  <dbl> <dbl>  <dbl>  <dbl>  <dbl>  <dbl>  <dbl>
#> 1 1     0      0.74  0    0.74    0     0.74   1.07   0.121 -0.623 -0.209
#> 2 1     0.25   2.84  2.82 0.0178  3.85 -1.01  -1.46   0.121 -0.623 -0.209
#> 3 1     0.570  6.57  5.06 1.51    6.76 -0.191 -0.277  0.121 -0.623 -0.209
#> # ... with 129 more rows, and 7 more variables: ka <dbl>, cl <dbl>,
#> #   v <dbl>, rx1c <dbl>, Central <dbl>, rx0 <dbl>, rx1 <dbl>

vpc(fit, show=list(obs_dv=TRUE))
#> Compiling VPC model...done
#> done (1.19 sec)

Created on 2019-01-01 by the reprex package (v0.2.1)

ryamy commented 5 years ago

Now I can figure out problem by your comment. As following, I overloaded vpc library and this resulted in silent VPC plots. Using nlmixr::vpc, it works completely fine.

Thanks for quick response and your kindly efforts!

`

library(vpc) Attaching package: 'vpc' The following object is masked from 'package:nlmixr': vpc

vpc(fit, show=list(obs_dv=TRUE)) ## does not work

nlmixr::vpc(fit, show=list(obs_dv=TRUE)) ## work Compiling model...done done (0.28 sec) `