Started R programming in simirt

main
Corentin Choisy 1 year ago
parent 59bc529e70
commit a82848938e

@ -0,0 +1,65 @@
simIRT <- function(NBOBS=2000,DIM,MU,COV,COVM,DIS,DIF,PMI,PMAX,ACC,CLEAR,STORE,REP,PREF,DRAW,
DRAWALL,ICC,GR=0,RAND,DEL=0,RSM1,RSM2,THR,TIT,PCM,ID,GENP,GENI) {
if (GR < 0 | GR > 1) {
stop('Error 198: The GR option defines a probability. The values defined by this option must be greater (or equal) to 0 and lesser (or equal) to 1.')
}
if ( is.null(CLEAR) & is.null(STORE) ) {
stop('Error 198: You must use at least one of these two options: clear and/or store.')
}
if (!is.null(DIM)) {
nbdim <- length(DIM)
if (nbdim > 2 & is.null(COVM)) {
stop('Error 198: You can simulate data with one or two dimensions, and you have indicated more dimensions in the DIM option. Please correct it.')
}
if (!is.null(COVM)) {
nbrowcovm <- nrow(COVM)
if (nbdim != nbrowcovm) {
stop('Error 198: DIM and COVM dimension mismatch. Please correct.')
}
}
nbitems <- sum(DIM)
if (!is.null(DIF)) {
nbdiff <- length(DIF)
tmp <- DIF[1]
if (tmp=='gauss' | tmp=='uniform') {
typediff <- tmp
}
else if (nbdiff != nbitems) {
stop('Error 198: "You have indicated a number of difficulty parameters (DIF option) different of the number of items to simulate (DIM option). Please correct these options.')
}
}
else if (is.null(DIF)) {
DIF <- vector(mode='list', length=DIM)
for (d in seq(1,DIM)) {
DIF[[d]] <- c('gauss',0,1)
}
typediff <- 'gauss'
nbdiff <- length(DIF)*3
}
}
}

@ -112,6 +112,12 @@ if "`dim'"!="" {
local nbdiff:word count `diff'
}
}
else if "`dim'"==""{
if "`diff'"==""&"`pcm'"=="" {
di in red "{p 0 0 0}You must indicate the number of items to simulate with the {hi:dim}, the {hi:pcm} or the {hi:diff} option(s)."

Loading…
Cancel
Save