Learn R Programming

BAT (version 2.9.6)

aic: 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)

Value

The AIC or AICc value.

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab