aic {BAT} | R Documentation |
Calculates the Akaike Information Criterion (AIC) of any model based on observed and estimated values.
aic(obs, est = NULL, param = 0, correct = FALSE)
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. |
Useful for models or functions that do not provide logLik values.
The AIC or AICc value.
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)