###Example: A brief simulation study###
#generate true values and response matrix
set.seed(10)
library(IRTBEMM)
I=500 #set the number of examinees is 500
J=10 #set the number of items is 10
true.beta=rnorm(J,0,1) #simulate true difficulty parameters
true.gamma=rnorm(J,-1.39,0.5) #simulate true guessing parameters
true.th=rnorm(I,0,1) #simulate true theta parameters
true.par=list(Beta=true.beta, Gamma=true.gamma) #make a list
response=matrix(NA,I,J) #Create a array to save response data
for (i in 1:I){
#calucate the probability of 1PLG
P=Prob.model(X=true.th[i], Model='1PLG', Par.est0=true.par)
response[i,]=rbinom(J,1,P) #simulate the response
}
#To save example running time, we set the Tol to 0.1
#Obtain the Bayesian modal estimation (BME) using default priors
#Estimate model via BEMM algorithm
bme.res=BEMM.1PLG(response, Tol=0.1)
bme.res$Est.ItemPars #show item estimates
bme.res$Est.Theta #show ability estimates
bme.res$Loglikelihood #show log-likelihood
bme.res$EM.Map #show EM iteration history
bme.res$fits.test #show model fits information
#Obtain the maximum likelihood estimation (MLE) by setting Prior=NA
#Estimate model via EMM algorithm
mle.res=BEMM.1PLG(response, PriorBeta=NA, PriorGamma=NA, Tol=0.1)
mle.res$Est.ItemPars #show item estimates
mle.res$Est.Theta #show ability estimates
mle.res$Loglikelihood #show log-likelihood
mle.res$EM.Map #show EM iteration history
mle.res$fits.test #show model fits information
Run the code above in your browser using DataLab