summary(exam1) # The names of the students are the row names
# Fit a simple Rasch model.
# First, remove all questions and people who were totally correct or wrong
exam1.1 <- exam1 [, colMeans(exam1 ) > 0]
exam1.1 <- exam1.1[, colMeans(exam1.1) < 1]
exam1.1 <- exam1.1[rowMeans(exam1.1) > 0, ]
exam1.1 <- exam1.1[rowMeans(exam1.1) < 1, ]
Y.matrix <- rdata <- exam1.1
if (FALSE) # The following needs: library(VGAM)
rfit <- rcim(Y.matrix, family = binomialff(multiple.responses = TRUE),
trace = TRUE)
coef(rfit) # Row and column effects
constraints(rfit, matrix = TRUE) # Constraint matrices side-by-side
dim(model.matrix(rfit, type = "vlm")) # 'Big' VLM matrix
if (FALSE) # This plot shows the (main) row and column effects
par(mfrow = c(1, 2), las = 1, mar = c(4.5, 4.4, 2, 0.9) + 0.1)
saved <- plot(rfit, rcol = "blue", ccol = "orange",
cylab = "Item effects", rylab = "Person effects",
rxlab = "", cxlab = "")
names(saved@post) # Some useful output put here
cbind(saved@post$row.effects)
cbind(saved@post$raw.row.effects)
round(cbind(-saved@post$col.effects), dig = 3)
round(cbind(-saved@post$raw.col.effects), dig = 3)
round(matrix(-saved@post$raw.col.effects, ncol = 1, # Rename for humans
dimnames = list(colnames(Y.matrix), NULL)), dig = 3)
Run the code above in your browser using DataLab