Perform model comparison for a fitted [pk()] object.
# S3 method for pk
compare_models(
obj,
newdata = NULL,
model = NULL,
method = NULL,
criterion = "AIC",
...
)
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
A [pk()] model object. Must be fitted, or the function will exit with an error.
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`.
Character: One or more of the models fitted. Default `NULL` to return TK stats for all models.
Character: One or more of the [optimx::optimx()] methods used. Default `NULL` to return TK stats for all methods.
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.
Caroline Ring
Models are compared according to the goodness-of-fit criterion named in "criterion", and the name of the winning model is returned.