knitr::opts_chunk$set( collapse = TRUE, comment = "#>", message = FALSE, warning = FALSE, out.width = "100%" )
You can simply add co-variances between two random effects by adding
the effects together in the model specification block, that is
eta.cl+eta.v ~
. After that statement, you specify the lower
triangular matrix of the fit with c()
.
An example of this is the phenobarbitol data:
## Load phenobarbitol data library(nlmixr2)
pheno <- function() { ini({ tcl <- log(0.008) # typical value of clearance tv <- log(0.6) # typical value of volume ## var(eta.cl) eta.cl + eta.v ~ c(1, 0.01, 1) ## cov(eta.cl, eta.v), var(eta.v) # interindividual variability on clearance and volume add.err <- 0.1 # residual variability }) model({ cl <- exp(tcl + eta.cl) # individual value of clearance v <- exp(tv + eta.v) # individual value of volume ke <- cl / v # elimination rate constant d/dt(A1) = - ke * A1 # model differential equation cp = A1 / v # concentration in plasma cp ~ add(add.err) # define error model }) }
fit <- nlmixr(pheno, pheno_sd, "saem", control=list(print=0), table=list(cwres=TRUE, npde=TRUE)) print(fit)
plot(fit)
Those individual plots are not that great, it would be better to see
the actual curves; You can with augPred
plot(augPred(fit))
library(ggplot2) p1 <- vpcPlot(fit, show=list(obs_dv=TRUE)); p1 <- p1 + ylab("Concentrations") ## A prediction-corrected VPC p2 <- vpcPlot(fit, pred_corr = TRUE, show=list(obs_dv=TRUE)) p2 <- p2 + ylab("Prediction-Corrected Concentrations") library(patchwork) p1 / p2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.