rxode2
unexpected simulation
#655
Answered
by
mattfidler
mattfidler
asked this question in
Q&A
-
library(rxode2)
#> rxode2 2.1.2 using 8 threads (see ?getRxThreads)
#> no cache: create with `rxCreateCache()`
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
# First fit with if statement to indicate diff IV/PO
modA <- function() {
ini({
tka <- 0.45; backTransform("exp") # Log Ka
tcl <- -7 # Log Cl
tv <- -8 # Log V
eta.ka ~ 0.6
eta.cl ~ 0.3
eta.v ~ 0.1
prop.sd <- 0.7
})
model({
if(ROUTE!=1) ka <- exp(tka + eta.ka)
cl <- exp(tcl + eta.cl)
v <- exp(tv + eta.v)
d/dt(depot) = -ka * depot
d/dt(center) = ka * depot - cl / v * center
cp = center / v
cp ~ prop(prop.sd)
})
}
et <- et(amount.units='mg', time.units='hours') %>%
et(dose=10) %>% et(seq(0,8,0.2)) %>% mutate(ROUTE=1)
sims <- rxSolve(modA,et)
#> ℹ parameter labels from comments will be replaced by 'label()'
#> Warning: some etas defaulted to non-mu referenced, possible parsing error: eta.ka
#> as a work-around try putting the mu-referenced expression on a simple line
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
plot(sims)
#> Warning: Removed 40 rows containing missing values (`geom_line()`).
#> `geom_line()`: Each group consists of only one observation.
#> ℹ Do you need to adjust the group aesthetic? Created on 2024-02-12 with reprex v2.1.0 |
Beta Was this translation helpful? Give feedback.
Answered by
mattfidler
Feb 12, 2024
Replies: 1 comment
-
@RichardHooijmaijers I believe this is expected behavior. What happens is the values in the problem are initialized to NA; If they are not changed in the simulation then they would remain NA. This means that all things related to I suppose a better model would be: library(rxode2)
#> rxode2 2.1.2 using 8 threads (see ?getRxThreads)
#> no cache: create with `rxCreateCache()`
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
# First fit with if statement to indicate diff IV/PO
modA <- function() {
ini({
tka <- 0.45; backTransform("exp") # Log Ka
tcl <- -7 # Log Cl
tv <- -8 # Log V
eta.ka ~ 0.6
eta.cl ~ 0.3
eta.v ~ 0.1
prop.sd <- 0.7
})
model({
ka <- 0
if(ROUTE!=1) ka <- exp(tka + eta.ka)
cl <- exp(tcl + eta.cl)
v <- exp(tv + eta.v)
d/dt(depot) = -ka * depot
d/dt(center) = ka * depot - cl / v * center
cp = center / v
cp ~ prop(prop.sd)
})
}
et <- et(amount.units='mg', time.units='hours') %>%
et(dose=10) %>% et(seq(0,8,0.2)) %>% mutate(ROUTE=1)
sims <- rxSolve(modA,et)
#> ℹ parameter labels from comments will be replaced by 'label()'
#> Warning: some etas defaulted to non-mu referenced, possible parsing error: eta.ka
#> as a work-around try putting the mu-referenced expression on a simple line
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
plot(sims) #note that a dose to the depot (that is turned off) doesn't make sense
#anyway, so consider dosing to the central compartment:
et <- et(amount.units='mg', time.units='hours') %>%
et(dose=10, cmt="center") %>% et(seq(0,8,0.2)) %>% mutate(ROUTE=1)
sims <- rxSolve(modA,et)
#> ℹ parameter labels from comments will be replaced by 'label()'
#> Warning: some etas defaulted to non-mu referenced, possible parsing error: eta.ka
#> as a work-around try putting the mu-referenced expression on a simple line
#> using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
plot(sims) Created on 2024-02-12 with reprex v2.1.0 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mattfidler
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@RichardHooijmaijers I believe this is expected behavior.
What happens is the values in the problem are initialized to NA; If they are not changed in the simulation then they would remain NA.
This means that all things related to
ka
ifroute == 1
would beNA
as well.I suppose a better model would be: