Closed mattfidler closed 1 year ago
The problem here is the f()
with the parentheses. It works without calling the function. (If it should work with calling the function, then I think you should just have to load rxode2, but tell me if you disagree and reopen the issue.)
library(nlmixr2lib)
f <- function() {
ini({
theta1 <- 1.37034
label("log Cl")
theta2 <- 4.19815
label("log Vc")
theta3 <- 1.38003
label("log Q")
theta4 <- 3.87657
label("log Vp")
RSV <- c(0, 0.196446, 1)
label("RSV")
eta2 ~ 0.0993872
eta3 ~ 0.101303
eta4 ~ 0.0730498
})
model({
cmt(CENTRAL)
cmt(PERI)
cl <- exp(theta1)
v <- exp(theta2 + eta2)
q <- exp(theta3 + eta3)
v2 <- exp(theta4 + eta4)
v1 <- v
scale1 <- v
k21 <- q/v2
k12 <- q/v
d/dt(CENTRAL) <- k21 * PERI - k12 * CENTRAL - cl * CENTRAL/v1
d/dt(PERI) <- -k21 * PERI + k12 * CENTRAL
f <- CENTRAL/scale1
ipred <- f
rescv <- RSV
ipred ~ prop(RSV)
})
}
f %>% addEta("theta1")
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#> ℹ promote `etatheta1` to between subject variability with initial estimate 0.1
#> ℹ change initial estimate of `etatheta1` to `0.1`
#> function ()
#> {
#> ini({
#> theta1 <- 1.37034
#> label("log Cl")
#> theta2 <- 4.19815
#> label("log Vc")
#> theta3 <- 1.38003
#> label("log Q")
#> theta4 <- 3.87657
#> label("log Vp")
#> RSV <- c(0, 0.196446, 1)
#> label("RSV")
#> eta2 ~ 0.0993872
#> eta3 ~ 0.101303
#> eta4 ~ 0.0730498
#> etatheta1 ~ 0.1
#> })
#> model({
#> cmt(CENTRAL)
#> cmt(PERI)
#> cl <- exp(theta1 + etatheta1)
#> v <- exp(theta2 + eta2)
#> q <- exp(theta3 + eta3)
#> v2 <- exp(theta4 + eta4)
#> v1 <- v
#> scale1 <- v
#> k21 <- q/v2
#> k12 <- q/v
#> d/dt(CENTRAL) <- k21 * PERI - k12 * CENTRAL - cl * CENTRAL/v1
#> d/dt(PERI) <- -k21 * PERI + k12 * CENTRAL
#> f <- CENTRAL/scale1
#> ipred <- f
#> rescv <- RSV
#> ipred ~ prop(RSV)
#> })
#> }
#> <environment: 0x000001a1612202d8>
f %>% addEta("cl")
#> → Adding eta to theta1 instead of cl due to mu-referencing
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#> ℹ promote `etatheta1` to between subject variability with initial estimate 0.1
#> ℹ change initial estimate of `etatheta1` to `0.1`
#> function ()
#> {
#> ini({
#> theta1 <- 1.37034
#> label("log Cl")
#> theta2 <- 4.19815
#> label("log Vc")
#> theta3 <- 1.38003
#> label("log Q")
#> theta4 <- 3.87657
#> label("log Vp")
#> RSV <- c(0, 0.196446, 1)
#> label("RSV")
#> eta2 ~ 0.0993872
#> eta3 ~ 0.101303
#> eta4 ~ 0.0730498
#> etatheta1 ~ 0.1
#> })
#> model({
#> cmt(CENTRAL)
#> cmt(PERI)
#> cl <- exp(theta1 + etatheta1)
#> v <- exp(theta2 + eta2)
#> q <- exp(theta3 + eta3)
#> v2 <- exp(theta4 + eta4)
#> v1 <- v
#> scale1 <- v
#> k21 <- q/v2
#> k12 <- q/v
#> d/dt(CENTRAL) <- k21 * PERI - k12 * CENTRAL - cl * CENTRAL/v1
#> d/dt(PERI) <- -k21 * PERI + k12 * CENTRAL
#> f <- CENTRAL/scale1
#> ipred <- f
#> rescv <- RSV
#> ipred ~ prop(RSV)
#> })
#> }
#> <environment: 0x000001a1644a65e0>
Created on 2023-03-10 with reprex v2.0.2
Otherwise this occurs:
Created on 2023-02-26 with reprex v2.0.2