++--- title: "ggPMX with nlmixr" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{ggPMX with nlmixr} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8}
knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) original_crayon_enabled <- getOption("crayon.enabled") options(crayon.enabled = FALSE)
library(ggPMX) has_nlmixr <- FALSE if (R.version$major >= 4) { library(nlmixr) has_nlmixr <- TRUE } `` It is simple to create a ggPMX controller for a nlmixr object. Using the theophylline example with a nlmixr model we have: ```r one.compartment <- function() { ini({ tka <- 0.45 # Log Ka tcl <- 1 # Log Cl tv <- 3.45 # Log V 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) d/dt(depot) = -ka * depot d/dt(center) = ka * depot - cl / v * center cp = center / v cp ~ add(add.sd) }) } if (has_nlmixr) nlmixr(one.compartment)
We run this model locally by:
if (has_nlmixr) { fit <- nlmixr(one.compartment, theo_sd, est="saem", control=list(print=0)) }
The fit
object is a nlmixr fit; You can read it into the nlmixr
controller by:
if (has_nlmixr) { fit %>% pmx_nlmixr(vpc = FALSE) -> ## VPC is turned on by default, can turn off. ctr ## Assigned to controller }
Once the controller is created, you can of course have the same types of diagnostic plots as the standard ggPMX package; Using the same examples as the user manual:
if (has_nlmixr) { ctr %>% pmx_plot_dv_pred ctr %>% pmx_plot_npde_time ctr %>% pmx_plot_vpc ctr %>% pmx_plot_eta_box ctr %>% pmx_plot_eta_matrix( shrink=pmx_shrink(size=3,hjust=1.5)) }
This shows the standard plots for theophylline
options(crayon.enabled = original_crayon_enabled)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.