aic: Akaike Information Criterion.

View source: R/BAT.R

aicR Documentation

Akaike Information Criterion.

Description

Calculates the Akaike Information Criterion (AIC) of any model based on observed and estimated values.

Usage

aic(obs, est = NULL, param = 0, correct = FALSE)

Arguments

obs

Either a model or a vector with observed values.

est

A vector with estimated values. Only used if obs is not a model.

param

Number of parameters in the model. If obs is a model param will be ignored and the number of parameters will be calculated from the model.

correct

Boolean indicating whether the corrected version of AIC (AICc) should be calculated, mostly for models with few observations.

Details

Useful for models or functions that do not provide logLik values.

Value

The AIC or AICc value.

Examples

obs = c(1,4,5,6)
est = c(0,1,4,7)

#example using values
aic(obs, est)
aic(obs, est, param = 1)
aic(obs, est, param = 1, correct = TRUE)

#example using model
mod = lm(obs ~ est)
aic(mod)
extractAIC(mod)[2]
aic(mod, correct = TRUE)


BAT documentation built on May 29, 2024, 7:35 a.m.

Related to aic in BAT...