Model block for rxode2/nlmixr models
Usage
# S3 method for class '`function`'
model(
x,
...,
append = NULL,
auto = getOption("rxode2.autoVarPiping", TRUE),
cov = NULL,
envir = parent.frame()
)
# S3 method for class 'rxUi'
model(
x,
...,
append = NULL,
auto = getOption("rxode2.autoVarPiping", TRUE),
cov = NULL,
envir = parent.frame()
)
# S3 method for class 'rxode2'
model(
x,
...,
append = NULL,
auto = getOption("rxode2.autoVarPiping", TRUE),
cov = NULL,
envir = parent.frame()
)
# S3 method for class 'rxModelVars'
model(
x,
...,
append = NULL,
auto = getOption("rxode2.autoVarPiping", TRUE),
cov = NULL,
envir = parent.frame()
)
model(
x,
...,
append = FALSE,
auto = getOption("rxode2.autoVarPiping", TRUE),
cov = NULL,
envir = parent.frame()
)
# Default S3 method
model(x, ..., append = FALSE, cov = NULL, envir = parent.frame())Arguments
- x
model expression
- ...
Other arguments
- append
This is a boolean to determine if the lines are appended in piping. The possible values for this is:
TRUEwhich is when the lines are appended to the model instead of replacedFALSEwhen the lines are replaced in the model (default)NAis when the lines are pre-pended to the model instead of replacedlhs expression, which will append the lines after the last observed line of the expressionlhs
- auto
This boolean tells if piping automatically selects the parameters should be characterized as a population parameter, between subject variability, or a covariate. When
TRUEthis automatic selection occurs. WhenFALSEthis automatic selection is turned off and everything is added as a covariate (which can be promoted to a parameter with theinistatement). By default this isTRUE, but it can be changed byoptions(rxode2.autoVarPiping=FALSE).- cov
is a character vector of variables that should be assumed to be covariates. This will override automatic promotion to a population parameter estimate (or an eta)
- envir
the
environmentin which unevaluated model expressions is to be evaluated. May also beNULL, a list, a data frame, a pairlist or an integer as specified tosys.call.
See also
Other Model UI and piping:
as.ini(),
as.model(),
as.rxUi(),
coef.rxUi(),
indLin(),
ini.rxUi(),
ini<-(),
linCmtMicro(),
linToOde(),
model<-(),
modelExtract(),
odeToLin(),
rxAppendModel(),
rxFixPop(),
rxFixRes(),
rxGetControl(),
rxRemoveControl(),
rxRename(),
rxSetControl(),
rxSetCovariateNamesForPiping(),
rxSetPipingAuto(),
rxUiDecompress(),
rxode2<-(),
update.rxUi(),
zeroRe()
Examples
# \donttest{
mod <- function() {
ini({
tka <- log(1.1)
tcl <- log(3)
tv <- log(30)
eta.cl ~ 0.1
add.sd <- 0.7
})
model({
ka <- exp(tka)
cl <- exp(tcl + eta.cl)
v <- exp(tv)
d/dt(depot) <- -ka * depot
d/dt(central) <- ka * depot - cl / v * central
cp <- central / v
cp ~ add(add.sd)
})
}
# extract the model block
model(mod)
#>
#>
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#> model({
#> ka <- exp(tka)
#> cl <- exp(tcl + eta.cl)
#> v <- exp(tv)
#> d/dt(depot) <- -ka * depot
#> d/dt(central) <- ka * depot - cl/v * central
#> cp <- central/v
#> cp ~ add(add.sd)
#> })
# replace a line; the new parameter tcl.wt is added to ini()
mod |> model(cl <- exp(tcl + eta.cl) * (WT / 70)^tcl.wt)
#>
#>
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#> ℹ add covariate `WT`
#> ℹ add population parameter `tcl.wt` and set estimate to 1
#> ── rxode2-based free-form 2-cmt ODE model ──────────────────────────────────────
#> ── Initalization: ──
#> Fixed Effects ($theta):
#> tka tcl tv add.sd tcl.wt
#> 0.09531018 1.09861229 3.40119738 0.70000000 1.00000000
#>
#> Omega ($omega):
#> eta.cl
#> eta.cl 0.1
#>
#> States ($state or $stateDf):
#> Compartment Number Compartment Name
#> 1 1 depot
#> 2 2 central
#> ── μ-referencing ($muRefTable): ──
#> theta eta level
#> 1 tcl eta.cl id
#>
#> ── Model (Normalized Syntax): ──
#> function() {
#> ini({
#> tka <- 0.0953101798043249
#> tcl <- 1.09861228866811
#> tv <- 3.40119738166216
#> add.sd <- c(0, 0.7)
#> tcl.wt <- 1
#> eta.cl ~ 0.1
#> })
#> model({
#> ka <- exp(tka)
#> cl <- exp(tcl + eta.cl) * (WT/70)^tcl.wt
#> v <- exp(tv)
#> d/dt(depot) <- -ka * depot
#> d/dt(central) <- ka * depot - cl/v * central
#> cp <- central/v
#> cp ~ add(add.sd)
#> })
#> }
# append a line after cp
mod |> model(auc <- cp * 12, append = cp)
#>
#>
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#> ── rxode2-based free-form 2-cmt ODE model ──────────────────────────────────────
#> ── Initalization: ──
#> Fixed Effects ($theta):
#> tka tcl tv add.sd
#> 0.09531018 1.09861229 3.40119738 0.70000000
#>
#> Omega ($omega):
#> eta.cl
#> eta.cl 0.1
#>
#> States ($state or $stateDf):
#> Compartment Number Compartment Name
#> 1 1 depot
#> 2 2 central
#> ── μ-referencing ($muRefTable): ──
#> theta eta level
#> 1 tcl eta.cl id
#>
#> ── Model (Normalized Syntax): ──
#> function() {
#> ini({
#> tka <- 0.0953101798043249
#> tcl <- 1.09861228866811
#> tv <- 3.40119738166216
#> add.sd <- c(0, 0.7)
#> eta.cl ~ 0.1
#> })
#> model({
#> ka <- exp(tka)
#> cl <- exp(tcl + eta.cl)
#> v <- exp(tv)
#> d/dt(depot) <- -ka * depot
#> d/dt(central) <- ka * depot - cl/v * central
#> cp <- central/v
#> cp ~ add(add.sd)
#> auc <- cp * 12
#> })
#> }
# }
