eval_likelihood function

Evaluation of Likelihood

Evaluation of Likelihood

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.

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)

Returns

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)