Learn R Programming

invivoPKfit (version 2.0.1)

compare_models.pk: Model comparison for [pk()] objects

Description

Perform model comparison for a fitted [pk()] object.

Usage

# S3 method for pk
compare_models(
  obj,
  newdata = NULL,
  model = NULL,
  method = NULL,
  criterion = "AIC",
  ...
)

Value

A `data.frame` with variables - `model`: The name of each model - `method`: The name of each method - A variable named for `criterion` (e.g. if `criterion = "AIC"` then the result will have a variable named `AIC`): The criterion value for each model/method

Arguments

obj

A [pk()] model object. Must be fitted, or the function will exit with an error.

newdata

Optional: A `data.frame` containing new data for which to compute the TK stats. Must contain at least variables `Chemical`, `Species`, `Route`, `Media`, `Dose`, and any other variables named in `tk_grouping`. Default `NULL`, to use the data in `obj$data`.

model

Character: One or more of the models fitted. Default `NULL` to return TK stats for all models.

method

Character: One or more of the [optimx::optimx()] methods used. Default `NULL` to return TK stats for all methods.

criterion

The name of a criterion function to use for model comparison. Default "AIC". Must be the name of a function that (as for `AIC`) accepts arguments `obj`, `newdata`, `method` and `model` (may accept other arguments, specified in `...`) and returns output as for `AIC`: a named list of numeric vectors (named for each of the model names in `model`), where each vector has elements named for each of the method names in `method`, containing the criterion value calculated for that model fitted using that method.

...

Optional: Other arguments to `criterion` function.

Author

Caroline Ring

Details

Models are compared according to the goodness-of-fit criterion named in "criterion", and the name of the winning model is returned.