-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eabe02f
commit 794a091
Showing
1 changed file
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
``` |