diff --git a/vignettes/articles/simulate-new-dosing.Rmd b/vignettes/articles/simulate-new-dosing.Rmd new file mode 100644 index 0000000..9f6ff1a --- /dev/null +++ b/vignettes/articles/simulate-new-dosing.Rmd @@ -0,0 +1,89 @@ +--- +title: "Simulate New dosing from Monolix model" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Simulate New dosing from Monolix model} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +library(rxode2) +setRxThreads(1L) +library(data.table) +setDTthreads(1L) +``` + +This page shows a simple work-flow for directly simulating a different +dosing paradigm than what was modeled. + + +## Step 1: Import the model + +```{r setup} +library(monolix2rx) +library(rxode2) + +library(monolix2rx) +# You use the path to the monolix mlxtran file + +library(monolix2rx) +# You use the path to the monolix mlxtran file + +# In this case we will us the theophylline project included in monolix2rx +pkgTheo <- system.file("theo/theophylline_project.mlxtran", package="monolix2rx") + +# Note you have to setup monolix2rx to use the model library or save +# the model as a separate file +mod <- monolix2rx(pkgTheo) + +print(mod) + +``` + +## Step 2: Look at a different dosing paradigm + +Lets say that in this case instead of a single dose, we want to see +what the concentration profile is with a single day of BID dosing. +In this case is done by creating a [quick event table](https://nlmixr2.github.io/rxode2/articles/rxode2-event-table.html): + +```{r eventTable} +ev <- et(amt=4, ii=12, until=24) %>% + et(list(c(0, 2), # add observations in windows + c(4, 6), + c(8, 12), + c(14, 18), + c(20, 26), + c(28, 32), + c(32, 36), + c(36, 44))) %>% + et(id=1:10) +``` + +## Step 3: solve using `rxode2` + +In this step, we solve the model with the new event table for the 10 +subjects: + +```{r solve} +s <- rxSolve(mod, ev) +``` + +Note that since this is a `nonmem2rx` model, the default solving will +match the tolerances and methods specified in your `NONMEM` model. + +## Step 4: exploring the simulation (by plotting) + +This solved object acts the same as any other `rxode2` solved object, +so you can use the `plot()` function to see the individual profiles +you simulated: + +```{r plot} +library(ggplot2) +plot(s, ipredSim) + + ylab("Concentrations") +```