###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.a=runif(J,0.4,2) #simulate true discrimination parameters
true.b=rnorm(J,0,1) #simulate true difficulty parameters
true.c=rbeta(J,2,8) #simulate true guessing parameters
true.s=rbeta(J,2,8) #simulate true slipping parameters
true.th=rnorm(I,0,1) #simulate true theta parameters
true.par=list(A=true.a, B=true.b, C=true.c, S=true.s) #make a list
response=matrix(NA,I,J) #Create a array to save response data
for (i in 1:I){
#calucate the probability of 4PL
P=Prob.model(X=true.th[i], Model='4PL', Par.est0=true.par, D=1.702)
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.4PL(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.4PL(response, Tol=0.1,
PriorA=NA, PriorB=NA, PriorC=NA, PriorS=NA)
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