if (FALSE) {
#############################################################################
# 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) ))
}
Run the code above in your browser using DataLab