BIC: Compute Bayesian 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 number of parameters times log of number of observations. See Schwarz (1978) for details.

Usage

1
BIC(logLikelihood, noPar, noObs)

Arguments

logLikelihood

Either a natural logarithm 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.

noObs

Number of observations used to obtain the maximum likelihood of the model.

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 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 BIC value, both give the same value
BIC(logLikelihood1, 3, 100)
BIC(logLikelihood2, 3, length(logLikelihood2))

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