Description Usage Arguments Value Examples
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.
1 |
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. |
The AIC value of the model in a form of a scalar.
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.