myN <- 250
myMean <- 0
mySd <- 2
myGroups <- c("gfit", "bfit")
myAbilities <- rnorm(myN, myMean, mySd)
# students with large weights and unperturbed responses (good fit)
# and students with small weights and perturbed responses (bad fit)
myData <- data.frame(
ability = myAbilities,
group = factor(sample(x = myGroups, size = myN, replace = TRUE))
)
myData$weight <- ifelse(myData$group == myGroups[1], 1, 0.001)
myItems <- list()
myItems[[1]] <- matrix(c(
0, 0, 0 , 1,
1, 1, -0.2, 1,
2, 1, 0.2 , 1
), ncol = 4, byrow = TRUE)
myPerturbations<- list()
myPerturbations[[1]] <- list()
myPerturbations[[1]] <- append(myPerturbations[[1]], 1L)
myPerturbations[[1]] <- append(myPerturbations[[1]], "discrimination")
myPerturbations[[1]] <- append(myPerturbations[[1]], 0.50)
myPerturbations[[1]] <- append(myPerturbations[[1]], 0)
myPerturbations[[1]] <- append(myPerturbations[[1]], "bfit")
names(myPerturbations[[1]]) <- c("item", "type", "factor", "pivot", "group")
myResponses <- genResponses(
abilities = myData$ability, itemParams = myItems, perturbR = myPerturbations,
groups = myData$group
)
Run the code above in your browser using DataLab