Estimate an nlmixr2 model loading the model from a targets indirect hash storage
Source:R/indirection.R
nlmixr2_indirect.RdThis is the command used by the fit_simple target generated by
tar_nlmixr(); it is not typically invoked by end users.
Usage
nlmixr2_indirect(
object,
data,
est,
control,
directory = file.path(targets::tar_config_get("store"), "user/nlmixr2"),
error = c("stop", "continue")
)Arguments
- object
Fitted object or function specifying the model.
- data
nlmixr data
- est
estimation method (all methods are shown by `nlmixr2AllEst()`). Methods can be added for other tools
- control
The estimation control object. These are expected to be different for each type of estimation method
- directory
Cache directory to load the simplified
nlmixruifrom. Defaults tofile.path(targets::tar_config_get("store"), "user/nlmixr2"), mirroring the convention used bytargets' ownstore = targets::tar_config_get("store")defaults — the path resolves at call time against whatever store the user has configured for the runningtar_make()(e.g. atempdir()location set viatargets::tar_config_set()).- error
What should happen if the estimation step throws an error?
"stop"(the default) lets the error propagate, haltingtargets::tar_make()as usual."continue"catches the error and stores a failure sentinel (an object of classnlmixr2targetsError, which also inherits from"try-error") carrying the error message, so a single failed model does not stop the rest of the pipeline. Detect a failed fit withinherits(fit, "nlmixr2targetsError")or the broaderinherits(fit, "try-error").
Value
An nlmixr2 fit object, as returned by nlmixr2est::nlmixr(). When
error = "continue" and the estimation step fails, a failure sentinel of
class nlmixr2targetsError (which also inherits from "try-error") is
returned instead; see tar_nlmixr().
Details
object is the md5 hash returned by nlmixr_object_simplify() and stored
as the object_simple target in the pipeline. nlmixr2_indirect() loads
the simplified nlmixrui object from the nlmixr2targets indirect cache
(under <targets store>/user/nlmixr2/) and passes it to
nlmixr2est::nlmixr() along with data, est, and control.
Routing the simplified ui through a small character-hash target rather than
a target whose value is the ui object keeps the dependency hash for the
fit_simple target independent of large rxUi internals, so cosmetic edits
to labels or metadata (which nlmixr_object_simplify() strips before
caching) do not invalidate the cached fit.