Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

eval_likelihood

Evaluation of Likelihood


Description

The function eval_likelihood evaluates the likelihood given item responses and item response probabilities.

The function prep_data_long_format stores the matrix of item responses in a long format omitted all missing responses.

Usage

eval_likelihood(data, irfprob, prior=NULL, normalization=FALSE, N=NULL)

prep_data_long_format(data)

Arguments

data

Dataset containing item responses in wide format or long format (generated by prep_data_long_format).

irfprob

Array containing item responses probabilities, format see IRT.irfprob

prior

Optional prior (matrix or vector)

normalization

Logical indicating whether posterior should be normalized

N

Number of persons (optional)

Value

Numeric matrix

Examples

## Not run: 
#############################################################################
# EXAMPLE 1: Likelihood data.ecpe
#############################################################################

data(data.ecpe, package="CDM")
dat <- data.ecpe$dat[,-1]
Q <- data.ecpe$q.matrix

#*** store data matrix in long format
data_long <- CDM::prep_data_long_format(data)
str(data_long)

#** estimate GDINA model
mod <- CDM::gdina(dat, q.matrix=Q)
summary(mod)

#** extract data, item response functions and prior
data <- CDM::IRT.data(mod)
irfprob <- CDM::IRT.irfprob(mod)
prob_theta <- attr( irfprob, "prob.theta")

#** compute likelihood
lmod <- CDM::eval_likelihood(data=data, irfprob=irfprob)
max( abs( lmod - CDM::IRT.likelihood(mod) ))

#** compute posterior
pmod <- CDM::eval_likelihood(data=data, irfprob=irfprob, prior=prob.theta,
            normalization=TRUE)
max( abs( pmod - CDM::IRT.posterior(mod) ))

## End(Not run)

CDM

Cognitive Diagnosis Modeling

v7.5-15
GPL (>= 2)
Authors
Alexander Robitzsch [aut, cre], Thomas Kiefer [aut], Ann Cathrice George [aut], Ali Uenlue [aut]
Initial release
2020-03-10 14:19:21

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.