-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
132 lines (92 loc) · 2.42 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---
title: "mrgsim.sa: sensitivity analysis with mrgsolve"
output: github_document
---
A simple, clean workflow for sensitivity analysis with mrgsolve.
<hr>
<BR>
```{r, include = FALSE}
knitr::opts_chunk$set(
comment = ".",
fig.path = "man/figures/README-",
fig.width = 8.5
)
options(tibble.print_min = 5, tibble.print_max = 5)
```
```{r, message = FALSE, warning = FALSE}
library(mrgsim.sa)
```
```{r}
mod <- mread("pk1", modlib(), end = 48, delta = 0.1)
param(mod)
```
## PK model sensitivity analysis by factor
The nominal (in model) parameter value is divided
and multiplied by a factor, generating minimum and maximum
bounds for simulating a sequence of parameter values
```{r}
out <-
mod %>%
ev(amt = 100) %>%
select_par(CL, V) %>%
parseq_fct(.n=8) %>%
sens_each()
sens_plot(out, "CP")
```
The simulated data is returned in a long format
```{r}
out
```
And you can plot with more informative color scale and legend
```{r}
sens_plot(out, "CP", grid = TRUE)
```
## HIV viral dynamic model
We look at latent infected cell pool development over ten years at different
"burst" size, or the number of HIV particles released when one cell lyses.
```{r}
mod <- mread("hiv", "inst/example")
mod %>%
update(end = 365*10) %>%
parseq_range(N = c(900,1500), .n = 10) %>%
sens_each(tscale = 1/365) %>%
sens_plot("L", grid = TRUE)
```
## Sensitivity analysis on custom sequences
The model is rifampicin PBPK.
```{r}
mod <- mread("inst/example/rifampicin.cpp") %>% update(delta = 0.1)
mod %>%
ev(amt = 600) %>%
parseq_manual(
SFKp = seq_fct(.$SFKp, n = 20),
Kp_muscle = seq_even(0.001, 0.1, n = 6)
) %>%
sens_each() %>%
sens_plot("Ccentral")
```
# Simulate a grid
To this point, we have always used `sens_each` so that each value for each
parameter is simulated one at a time. Now, simulate the grid or all
combinations.
We use `parseq_cv` here, which generates lower and upper bounds
for the range using 50% coefficient of variation.
```{r, fig.height = 7}
out <-
mod %>%
update(outvars = "Ccentral") %>%
ev(amt = 600) %>%
parseq_cv(fBCLint_all_kg, .n = 7) %>%
parseq_cv(SFKp, Kp_muscle, .n = 3) %>%
sens_grid(recsort = 3)
out
out %>% sens_plot("Ccentral")
```
# Local sensitivity analysis
```{r}
mod <- modlib("pk2", delta = 0.1, end = 72)
doses <- ev(amt = 100)
out <- lsa(mod, var = "CP", par = "CL,V2,Q", events = doses)
out
lsa_plot(out, pal = NULL)
```