You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
simul_these/Scripts/R/generate_item_difficulties.R

47 lines
978 B
R

###################################################
# Function: generate_diff_irt
# Generates item difficulty threshold matrix for
# IRT model simulation
###################################################
generate_diff_irt <- function(J=7,M=4) {
# if J=7, item 5. Else, item 3
if(J==7){
i <- 5
}
if(J==4){
i <- 3
}
difficulties = matrix(c(0), J,M-1)
rownames(difficulties)=paste("item",1:J)
colnames(difficulties)=paste("Moda", 1:(M-1))
for (j in 1:J){
difficulties[j,1] = qnorm(j/(J+1))
}
if (M>2) {
for (j in 1:J){
for (m in 2:(M-1)){
difficulties[j,m]= difficulties[j,1]+(m-1)*2/(M-2)
}
}
}
difficulties = difficulties-mean(difficulties)
return(difficulties)
}
###################################################
# GENERATE MATRIX FOR SIMULATION
###################################################
generate_diff_irt(J=4,M=2)
generate_diff_irt(J=4,M=4)
generate_diff_irt(J=7,M=2)
generate_diff_irt(J=7,M=4)