Description Usage Arguments Value References Examples
Log likelihood (log loss)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
obs |
A numeric vector or matrix, the observed data. Can be continuous values or dicrete. Can be aggregated, and if so you must supply |
pred |
A numeric vector or matrix with predictions, in the same order as |
pdf |
A string, probability density function;, allowed are |
na.rm |
(optional) Logical (default |
n |
(optional) Integer or integer vector (default: 1), number of observations underlying obs if |
saturated |
(optional) logical, compute saturated model (observed proportions as prediction, which approximates the highest possible likelihood). If so |
eps |
(optional) small numeric to offset predictions from zero in binomial pdf by substituting |
binomial.coef |
(optional) Logical (defaul is |
sigma |
(optional) Standard deviation of the normal distribution, required for |
a, b |
(optional) A number, lower/upper bound of the truncated pdf, required if |
... |
Other parameters, currently ignored. |
The log likelihood of obs
given pred
. Lokelihoods are computed without the binomial coefficient.
Busemeyer, J. R., & Diederich, A. (2010). Nonlinear parameter estimation. In Cognitive Modeling (pp. 43–84). Thousand Oaks, CAL: SAGE Publications.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Example from Busemeyer & Diederich (2010)
# Observed relative frequencies of choice 1 from 11 conditions
obs <- c(.9538, .9107, .9204, .9029, .8515, .9197,
.7970, .8228, .8191, .7277, .7276)
# Predictions for each of the 11 conditions
pred <- c(.9526, .9168, .8721, .8229, .7736, .7277,
.6871, .6523, .6232, .5993, .5798)
n <- 200 # number of observations
# lnL in paper is -969.9514, < 0.1 % deviation
ll <- Loglikelihood(obs = obs, pred = pred, n = 200)
# all.equal(ll, -969.9514, 0.001)
# lnLS in paper is -879.9013, < 1 % deviation due to rounding
llsat <- Loglikelihood(obs = obs, n = 200, saturated = TRUE)
# all.equal(llsat, -879.9013, .01)
# Using the raw data
# Recreate the raw data (observations 0 or 1)
obsraw <- rep(rep(0:1, 11), round(c(t(cbind(1-obs, obs))) * 200))
predraw <- rep(pred, each = 200)
ll <- Loglikelihood(obs = obsraw, pred = predraw)
# all.equal(ll, -969.9514, 0.001)
llsat <- Loglikelihood(obs = obsraw, pred = predraw, saturated = TRUE)
# all.equal(llsat, -879.9013, .01)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.