-
Notifications
You must be signed in to change notification settings - Fork 0
/
04-syntax.Rmd
64 lines (42 loc) · 1.82 KB
/
04-syntax.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
# rxode2 syntax {#syntax}
This briefly describes the syntax used to define models
that `rxode2` will translate into R-callable compiled code. It also
describes the communication of variables between `R` and the
`rxode2` modeling specification.
## Example
```
# An rxode2 model specification (this line is a comment).
if(comed==0){ # concomitant medication (con-med)?
F = 1.0; # full bioavailability w.o. con-med
}
else {
F = 0.80; # 20% reduced bioavailability
}
C2 = centr/V2; # concentration in the central compartment
C3 = peri/V3; # concentration in the peripheral compartment
# ODE describing the PK and PD
d/dt(depot) = -KA*depot;
d/dt(centr) = F*KA*depot - CL*C2 - Q*C2 + Q*C3;
d/dt(peri) = Q*C2 - Q*C3;
d/dt(eff) = Kin - Kout*(1-C2/(EC50+C2))*eff;
```
## Syntax
```{r syntax1, echo=FALSE, results='asis'}
cat(unlist(knitr::knit_child(text = gsub("vignette", "section",
gsub("http.*event.*\\.html", "#events", readLines('rxode2/man/rmdhunks/rxode2-syntax-hunk.Rmd'))),
envir = environment(), quiet = TRUE)), sep="\n")
```
## cmt() changing compartment numbers for states
The compartment order can be changed with the `cmt()` syntax in the
model. To understand what the `cmt()` can do you need to understand
how `rxode2` numbers the compartments.
Below is an example of how rxode2 numbers compartments
### How rxode2 numbers compartments
```{r syntaxCmt, child='rxode2/man/rmdhunks/rxode2-cmt-assign.Rmd'}
```
### Changing compartments by pre-declaring with `cmt()`
```{r syntaxCmt, child='rxode2/man/rmdhunks/rxode2-cmt-preassign-1.Rmd'}
```
### Appending compartments to the model with `cmt()`
```{r syntaxCmtAppend, child='rxode2/man/rmdhunks/rxode2-cmt-preassign-2.Rmd'}
```