cp_AIC {gspcr}R Documentation

Compute Akaike's information criterion

Description

Computes Akaike's information criterion for comparing competing models.

Usage

cp_AIC(ll, k)

Arguments

ll

numeric vector of length 1 (or an object of class 'logLik') storing the log-likelihood of the model of interest

k

numeric vector of length 1 storing the number of parameters estimated by the model

Value

numeric vector of length 1 storing the computed AIC.

Author(s)

Edoardo Costantini, 2023

Examples

# Fit some model
lm_out <- lm(mpg ~ cyl + disp, data = mtcars)

# Compute AIC with your function
AIC_M <- cp_AIC(
    ll = logLik(lm_out),
    k = length(coef(lm_out)) + 1 # intercept + reg coefs + error variance
)

[Package gspcr version 0.9.5 Index]