Skip to contents

This function is typically not needed by end users.

Usage

nlmixr_data_simplify(
  data,
  object,
  table = list(),
  directory = file.path(targets::tar_config_get("store"), "user/nlmixr2"),
  est = NULL,
  control = NULL,
  covariates = NULL,
  error = c("stop", "continue")
)

Arguments

data

nlmixr data

object

The model, in either form nlmixr_object_covariates() accepts: an nlmixr ui object, or a character md5 hash identifying a simplified ui in the nlmixr2targets indirect cache.

table

The output table control object (like `tableControl()`)

directory

Cache directory to load the simplified nlmixrui from. Defaults to file.path(targets::tar_config_get("store"), "user/nlmixr2"), mirroring the convention used by targets' own store = targets::tar_config_get("store") defaults — the path resolves at call time against whatever store the user has configured for the running tar_make() (e.g. a tempdir() location set via targets::tar_config_set()).

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

covariates

The model's covariate column names, as returned by nlmixr_object_covariates(). Supply exactly one of object and covariates.

error

What should happen if any step of a model's chain throws an error? "stop" (the default) lets the error propagate, halting targets::tar_make() as usual. "continue" catches an error from any of the model's steps – simplifying the object, reading its covariates, simplifying the data, or the estimation itself – and stores a failure sentinel (an object of class nlmixr2targetsError, which also inherits from "try-error") carrying the error message. The sentinel is passed down the model's remaining steps to its final target, so a single failed model does not stop the rest of the pipeline. Detect a failed model with inherits(fit, "nlmixr2targetsError") or the broader inherits(fit, "try-error").

Value

The data with the nlmixr2 column lower case and on the left and the covariate columns on the right and alphabetically sorted.

Details

The standardization keeps columns that rxode2 and nlmixr2 use along with the covariates. Column order is standardized (rxode2 then nlmixr2 then alphabetically sorted covariates), and rxode2 and nlmixr2 column names are converted to lower case.

est and control only affect which columns are kept: with the default est = NULL, or any estimation method other than "vae", the standard and model covariate columns above are all that is kept. When est = "vae", the automated covariate selection searches subject-constant data columns beyond the covariates named in the model, so the candidate columns reported by nlmixr2est::vaeCovariates() (honoring the shapes, covCenterType, covCenter, and catCutoff settings in control) are kept as well. Columns the search cannot use (for example time-varying or partially-missing columns) are still dropped; the exclusion warnings that nlmixr2est::nlmixr() would raise for them are raised here instead, because the estimation step never sees the dropped columns.

The model is consulted only for its covariate names, so it can be given either as object or, already reduced to those names, as covariates. The targets generated by tar_nlmixr() pass covariates, so the data target depends on the covariate names rather than on the whole model: an edit to the model that leaves its covariates unchanged does not rebuild the simplified data.