## Simulate Responses according to the three-parameter ## Normal Ogive or Logistic Model. J.-P. Fox, University of Twente, Augustus 2010. # normal ogive or logistic Model # K: number of items # N: number of items # theta : latent variable # beta : difficulty parameter # guess : guessing parameter THREEPNO <- function(N,K) { theta <- rnorm(N) theta <- (theta - mean(theta))/sqrt(var(theta)) alpha <- rnorm(K,mean=1,sd=.1) beta <- rnorm(K,sd=.5) beta <- beta - mean(beta) guess <- runif(K,0,.25) par <- theta %*% matrix(alpha,nrow=1,ncol=K) - t( matrix(beta,nrow=K,ncol=N) ) #Normit probs <- matrix(pnorm(par),ncol = K,nrow = N) probs <- t(matrix(guess,ncol=N,nrow=K)) + (matrix(1,ncol=K,nrow=N)-t(matrix(guess,ncol=N,nrow=K)))*probs #Logit #probs <- matrix(1/(1+exp(-par)),ncol = K,nrow = N) Y <- matrix(runif(N*K),nrow = N, ncol = K) Y <- ifelse(Y < probs,1,0) return(list(Y,theta,alpha,beta,guess)) }