Cleaned up code

This commit is contained in:
2024-05-30 16:50:38 +02:00
parent 6086d74551
commit fd0d2de43f
50 changed files with 370 additions and 8057 deletions

View File

@ -0,0 +1,46 @@
###################################################
# 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)