Skip to contents

Get or set a named-numeric vector of forced parameters stored in a hidden slot of an rxode2 ui. Forced parameters override the values supplied in params/data and the model initial estimates on every solve of that ui (they are written into every subject/simulation column at solve setup, the same injection point used by par-loader hooks). Because the values live on the ui they travel with it – through model piping and into any nlmixr2 fit built from it – so the model stays self-contained and portable (e.g. a fit that carries trained neural-network weights re-solves, predicts and simulates with those weights with no external state).

Usage

rxForcedPars(ui)

rxForcedPars(ui) <- value

Arguments

ui

an rxode2 ui / model function.

value

named numeric vector of forced parameter values, or NULL.

Value

the getter returns the named numeric vector (or NULL); the setter returns the (modified) ui.

Details

The value is stored directly in the ui environment (not in the printed meta block, so it stays hidden) and registered as a sticky model item so it survives model piping. Names must be model parameters; names that are not model parameters are ignored at solve time. Set to NULL (or an empty vector) to clear.

Author

Matthew L. Fidler

Examples

# \donttest{
f <- function() {
  ini({
    tcl <- -2
  })
  model({
    cl <- exp(tcl) * WT
    d/dt(depot) <- -cl * depot
  })
}
u <- rxode2(f)
#>  
#>  
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
rxForcedPars(u) <- c(WT = 2)
rxForcedPars(u)
#> WT 
#>  2 
ev <- et(amt = 100) |> et(1:8)
ev$WT <- 1
# the forced WT = 2 overrides the data WT = 1
s <- rxSolve(u, ev)
#>  
#>  
rxInjectedPars(s)
#> WT 
#>  2 
rxForcedPars(u) <- NULL
# }