knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The vaplot package creates variability attribution plots for non-linear mixed effect models.
library(vaplot)
lst_file <- system.file("testdata", "derivatives_run4.lst", package = "vaplot") # read NM results & prepare data structure input <- prepare_va_nm(lst_file) omega <- input$omega omega[2,1] <- omega[2,1] <- 0.08 input2 <- update_omega(input, omega) # calculate variability attribution va_res <- compute_va(input, facets = "DVID") va_res2 <- compute_va(input2, facets = "DVID") plot_va_compare(va_res, va_res2, smooth = T) # generate va plot plot_va(va_res, smooth = T)
frem_path <- system.file("testdata", "frem_pheno", package = "vaplot") # read FREM results & prepare data structure input <- prepare_va_frem(frem_path) # calculate variability attribution va_res <- compute_va(input) # generate va plot plot_va(va_res, coloring = coloring_highlight_covs)
In addition to NONMEM, the package also supports NLME models written as a simple R function.
my_model <- function(time, theta, eta, eps, z){ v <- theta[1]*exp(eta[1]) cl <- theta[2]*exp(eta[2]) ka <- theta[3]*exp(eta[3]) k <- cl/v conc <- z["dose"]/v*ka/(ka-k)*(exp(-k*time)-exp(-ka*time)) y <- conc * (1 + eps[1]) return(y) } theta <- c(3, 5, 0.1) eta <- c(0,0,0) z <- c(dose = 10) time <- seq(0, 20, length.out = 40) plot(time, my_model(time, theta, eta, 0, z), type = "l") omega <- diag(c(0.2,0.1,0.5), 3, 3) sigma <- matrix(.05, 1, 1) input <- prepare_va_fun(my_model, theta, omega, sigma, time, z) va_res <- compute_va(input) plot_va(va_res)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.