compare_models: Fit several models and compare them

View source: R/compare.R

compare_modelsR Documentation

Fit several models and compare them

Description

Fits each model with estimate_parameters and returns a table ranked by AIC.

Usage

compare_models(
  data,
  models = c("gaussian", "t", "leverage", "skew_gaussian", "skew_gaussian_leverage",
    "skew_t", "skew_t_leverage"),
  ...
)

Arguments

data

A vector of observations.

models

Character vector of models. See estimate_parameters. The default is all models.

...

Additional arguments passed to estimate_parameters. silent = TRUE is used unless you set it.

Details

The table also shows if the optimizer converged and if the Hessian is positive definite. A model that fails one of these checks has unreliable estimates and standard errors, even when its AIC is small. A model that gives an error is reported with NA values and the error message.

Value

A data.table with one row for each model, ordered by AIC, and the columns model, n_par, log_lik, aic, bic, delta_aic (the difference to the smallest AIC), converged, pd_hessian and message. The fitted models are in the attribute "fits", a named list of stochvolTMB objects.

Examples


comparison <- compare_models(spy$log_return, models = c("gaussian", "t", "leverage"))
comparison
best <- attr(comparison, "fits")[[comparison$model[1]]]


stochvolTMB documentation built on Nov. 7, 2026, 5:08 p.m.