# NOT RUN {
# Simple example using a randomly generated ratings matrix
d <- as.numeric(sample(0:5, 200, replace = TRUE))
dm <- matrix(d, nrow = 20, ncol = 10)
m1 <- msd(dm, misfit = TRUE)
# Anchor first 5 item measures and first 10 person measures
im <- m1$item_measures
im[6:length(im)] <- NA
pm <- m1$person_measures
pm[11:length(pm)] <- NA
m2 <- msd(dm, items = im, persons = pm)
# To test the accuracy of msd using simdata, set the mean item measure to zero
# (axis origin in msd is the mean item measure) and the mean threshold to
# zero (any non-zero mean threshold is reflected in the person measures).
im <- runif(100, -2, 2)
im <- im - mean(im)
pm <- runif(100, -2, 2)
th <- sort(runif(5, -2, 2))
th <- th - mean(th)
d <- simdata(im, pm, th, missingProb = 0.15, minRating = 0)
m <- msd(d)
# Compare msd parameters to true values. Linear regression should
# yield a slope very close to 1 and an intercept very close to 0.
lm(m$item_measures ~ im)
lm(m$person_measures ~ pm)
lm(m$thresholds ~ th)
# }
Run the code above in your browser using DataLab