ols_aic: Akaike information criterion

View source: R/ols-information-criteria.R

ols_aicR Documentation

Akaike information criterion

Description

Akaike information criterion for model selection.

Usage

ols_aic(model, method = c("R", "STATA", "SAS"), corrected = FALSE)

Arguments

model

An object of class lm.

method

A character vector; specify the method to compute AIC. Valid options include R, STATA and SAS.

corrected

Logical; if TRUE, returns corrected akaike information criterion.

Details

AIC provides a means for model selection. Given a collection of models for the data, AIC estimates the quality of each model, relative to each of the other models. R and STATA use loglikelihood to compute AIC. SAS uses residual sum of squares. Below is the formula in each case:

R & STATA

AIC = -2(loglikelihood) + 2p

SAS

AIC = n * ln(SSE / n) + 2p

corrected

R

AIC = -2(loglikelihood) + 2k + \frac{2k(k + 1)}{n - k - 1}

where k is p + 1.

STATA

AIC = -2(loglikelihood) + 2p + \frac{2p(p + 1)}{n - p - 1}

SAS

AIC = n * ln(SSE / n) + ((n * (n + p)) / (n - p - 2))

where n is the sample size and p is the number of model parameters including intercept.

Value

Akaike information criterion of the model.

References

Akaike, H. (1969). “Fitting Autoregressive Models for Prediction.” Annals of the Institute of Statistical Mathematics 21:243–247.

Judge, G. G., Griffiths, W. E., Hill, R. C., and Lee, T.-C. (1980). The Theory and Practice of Econometrics. New York: John Wiley & Sons.

Akaike, H. (1974). A new look at the statistical model identification. IEEE Transactions on Automatic Control, 19(6), 716–723.

Hurvich, C. M. and Tsai, C.-L. (1989). Regression and time series model selection in small samples. Biometrika, 76(2), 297–307.

See Also

Other model selection criteria: ols_apc(), ols_fpe(), ols_hsp(), ols_mallows_cp(), ols_msep(), ols_sbc(), ols_sbic()

Examples

# using R computation method
model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars)
ols_aic(model)

# using STATA computation method
model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars)
ols_aic(model, method = 'STATA')

# using SAS computation method
model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars)
ols_aic(model, method = 'SAS')

# corrected akaike information criterion
model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars)
ols_aic(model, method = 'SAS', corrected = TRUE)
ols_aic(model, method = 'R', corrected = TRUE)
ols_aic(model, method = 'STATA', corrected = TRUE)


olsrr documentation built on Nov. 18, 2026, 5:07 p.m.