Learn R Programming

invivoPKfit (version 2.0.1)

do_fit.pk: Do fitting

Description

Fit PK model(s) for a `pk` object

Usage

# S3 method for pk
do_fit(obj, n_cores = NULL, rate_names = NULL, max_multiplier = NULL, ...)

Value

The same [pk] object, with element `fit` containing the fitted results for each model in `stat_model`.

Arguments

obj

A [pk] object.

n_cores

Number of cores used for parallel computing.

rate_names

The names of the rate units. Leave NULL to utilize default 1/hour.

max_multiplier

Numeric value for upper prediction limit (this number multiplied by maximum concentrations in each experiment). Default set to NULL does not apply this limit.

...

Additional arguments. Not currently in use.

Author

Caroline Ring, Gilberto Padilla Mercado

Details

This function estimates the parameters for each model in `stat_model` from the data, using numerical optimization implemented in [optimx::optimx()]. The optimization is done by maximizing the log-likelihood function implemented in [log_likelihood()] (technically, by minimizing the negative log-likelihood). Only the non-excluded observations are used.

Due to limitations of [optimx::optimx()], the log-likelihood function is forced to return finite values during this optimization. Impossible combinations of parameters (e.g., parameter values that produce negative predicted concentrations) should have a log-likelihood of `-Inf`, but due to this limitation, they instead have a log-likelihood of `-Machine.doublexmax`. This limitation means that the log-likelihood function is flat in regions of impossible parameter values. It is unlikely, but possible, that the optimizer might get "stuck" in such a flat region -- report convergence, but return a "bad" set of parameter values that produces non-physical predictions.

Before trusting the results of any fit, it is recommended to check the log-likelihood using [logLik()] and the Akaike Information Criterion using [AIC()], which check the log-likelihood *without* forcing it to return finite values.