aic: Akaike Information Criterion (AIC)

Description Usage Arguments Value References Examples

View source: R/criterion.R

Description

The Akaike Information Criterion's objective is to prevent model overfitting by adding a penalty term which penalizes more complex models. Its formal definition is:

-2*ln(L)+2*k

where L is the maximized value of the likelihood function. A smaller AIC value suggests that the model is a better fit for the data.

Usage

1
aic(model, X = NULL, y = NULL)

Arguments

model

A base R model object (e.g., lm())

X

Validation data as a 2D matrix of (observations, features). If NULL, extract X from model.

y

True labels as a 1D vector. If NULL, extract y from model.

Value

AIC value gets returned as a float.

References

https://en.wikipedia.org/wiki/Akaike_information_criterion

Examples

1
2
model <- lm(hp~., data=mtcars)
aic(model)

UBC-MDS/punisheR documentation built on May 25, 2019, 1:36 p.m.