AIC {stats} | R Documentation

## Akaike's An Information Criterion

### Description

Generic function calculating the Akaike information criterion for one or several fitted model objects for which a log-likelihood value can be obtained, according to the formula -2*log-likelihood + k*npar, where npar represents the number of parameters in the fitted model, and k = 2 for the usual AIC, or k = log(n) (n the number of observations) for the so-called BIC or SBC (Schwarz's Bayesian criterion).

### Usage

    AIC(object, ..., k = 2)

### Arguments

`object` | a fitted model object, for which there exists a `logLik` method to extract the corresponding log-likelihood, or an object inheriting from class `logLik`.
`...` | optionally more fitted model objects.
`k` | numeric, the penalty per parameter to be used; the default `k = 2` is the classical AIC.

### Details

The default method for `AIC`, `AIC.default()` entirely relies on the existence of a `logLik` method computing the log-likelihood for the given class.

When comparing fitted objects, the smaller the AIC, the better the fit.

The log-likelihood and hence the AIC is only defined up to an additive constant. Different constants have conventionally be used for different purposes and so `extractAIC` and `AIC` may give different values (and do for models of class `"lm"`: see the help for `extractAIC`).

### Value

If just one object is provided, returns a numeric value with the corresponding AIC (or BIC, or ..., depending on `k`); if multiple objects are provided, returns a `data.frame` with rows corresponding to the objects and columns representing the number of parameters in the model (`df`) and the AIC.

### Author(s)

Jose Pinheiro and Douglas Bates

### References

Sakamoto, Y., Ishiguro, M., and Kitagawa G. (1986). Akaike Information Criterion Statistics. D. Reidel Publishing Company.

### See Also

`extractAIC`, `logLik`.

### Examples

    lm1 <- lm(Fertility ~ . , data = swiss)
    AIC(lm1)
    stopifnot(all.equal(AIC(lm1),
                        AIC(logLik(lm1))))
    ## a version of BIC or Schwarz' BC :
    AIC(lm1, k = log(nrow(swiss)))

[Package stats version 2.8.1 Index]