AIC: Compute Akaike information criterion of the model.

Description Usage Arguments Value Examples

Description

This is a standard implementation where log likelihood is multiplied by -2 and penalty term is added in the form of 2 times the number of free parameters in the model. Optionally, finite sample correction can be used. See Burnham and Anderson (2002) for details.

Usage

1
AIC(logLikelihood, noPar, noObs = NA, correction = FALSE)

Arguments

logLikelihood

Either a log of the maximum likelihood of the model, or a vector of logged probabilities for each trial. Note that it should not be a negative of the log likelihood.

noPar

Number of free parameters in the model.

correction

TRUE if finite sample correction is needed, by default FALSE. Recommended to use if number of observations divided by number of free parameters is less than 40.

Value

The AIC value of the model in a form of a scalar.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 100 artificial trials with probability for each trial
set.seed(1234)
maxLikelihood <- runif(100)
# you can use either a final log of the maximum likelihood
logLikelihood1 <- sum(log(maxLikelihood))
# or logged probabilites of each trial
logLikelihood2 <- log(maxLikelihood)
# computing the AIC value, both give the same value
AIC(logLikelihood1, 3)
AIC(logLikelihood2, 3)
# if finite sample correction is used, then we need to supply number of observations as well
AIC(logLikelihood2, 3, length(logLikelihood2))

hstojic/cogmod documentation built on May 17, 2019, 6:16 p.m.