Skip to contents

Creates a comparison table of AIC, BIC, and other statistics for multiple fitted models. Useful for model selection.

Usage

compare(..., names = NULL)

Arguments

...

One or more femtofit objects to compare.

names

Optional character vector of model names. If not provided, names are extracted from the call or generated automatically.

Value

A data.frame with columns for each model's statistics, including log-likelihood, AIC, BIC, delta AIC, and AIC weights.

Details

Models are ranked by AIC. Delta AIC is calculated relative to the best model (lowest AIC). AIC weights represent the relative likelihood that each model is the best, assuming one of the models is true.

See also

anova.femtofit for likelihood ratio tests

Examples

if (FALSE) { # \dontrun{
# Fit competing models
m1 <- fit(function(mu) loglik_normal(mu, 1, x), c(mu = 0))
m2 <- fit(function(mu, sigma) loglik_normal(mu, sigma, x), c(mu = 0, sigma = 1))

# Compare models
compare(m1, m2, names = c("Fixed sigma", "Free sigma"))
} # }