Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
We received an email from a user who was interested in displaying results from a multifaceted model in WrightMap
. In the WrightMap
manual, we show how to use multifaceted results from ConQuest:
fpath <- system.file("extdata", package = "WrightMap") model4 <- CQmodel(file.path(fpath, "ex4a.mle"), file.path(fpath, "ex4a.shw")) wrightMap(model4, item.table = "rater", interactions = "rater*topic", step.table = "topic")
(See this tutorial for more details.)
But if your results aren’t from ConQuest, this example won’t be as useful to you. However, the basic WrightMap
function is program-independent. If you can put your results into a matrix, WrightMap
can graph it. The most important thing to remember is that WrightMap
treats rows as “items” and columns as “steps”. So if you would like to make a graph like the one above with your data, each rater (Amy, Beverley, etc.) should be associated with a column, and each topic (School, Family) with a row.
For this example, we will be using results from the R
package TAM
(created by Thomas Kiefer, Alexander Robitzsch, and Margaret Wu). We discussed using TAM
results in WrightMap in this post and this follow-up, using a simple dichotomous model. For this tutorial, we’ll use a item * rater model.
The setup and comments here are taken from the TAM
manual:
library(TAM) library(WrightMap) data(data.ex10) dat <- data.ex10 facets <- dat[, "rater", drop = FALSE] # define facet (rater) pid <- dat$pid # define person identifier (a person occurs multiple times) resp <- dat[, -c(1:2)] # item response data formulaA <- ~item * rater # formula mod <- tam.mml.mfr(resp = resp, facets = facets, formulaA = formulaA, pid = dat$pid) persons.mod <- tam.wle(mod) theta <- persons.mod$theta
The tam.thresholds
command provides us with the estimated difficulty for each item-by-rater (item + rater + item * rater
).
thr <- tam.threshold(mod) item.labs <- c("I0001", "I0002", "I0003", "I0004", "I0005") rater.labs <- c("rater1", "rater2", "rater3")
Now we need to turn it into a matrix formatted the way WrightMap
expects. We could organize it by item:
thr1 <- matrix(thr, nrow = 5, byrow = TRUE) wrightMap(theta, thr1, label.items = item.labs, thr.lab.text = rep(rater.labs, each = 5))
Or by rater:
thr2 <- matrix(thr, nrow = 3) wrightMap(theta, thr2, label.items = rater.labs, thr.lab.text = rep(item.labs, each = 3), axis.items = "Raters")
Another option is to show the item
, rater
, and item * rater
parameters separately. We can get these from the xsi.facets
table.
pars <- mod$xsi.facets$xsi facet <- mod$xsi.facets$facet item.par <- pars[facet == "item"] rater.par <- pars[facet == "rater"] item_rat <- pars[facet == "item:rater"]
We could put them in separate bands, adding NA
to make them all the same length.
len <- length(item_rat) item.long <- c(item.par, rep(NA, len - length(item.par))) rater.long <- c(rater.par, rep(NA, len - length(rater.par))) ir.labs <- mod$xsi.facets$parameter[facet == "item:rater"] wrightMap(theta, rbind(item.long, rater.long, item_rat), label.items = c("Items", "Raters", "Item*Raters"), thr.lab.text = rbind(item.labs, rater.labs, ir.labs), axis.items = "")
But the item*rater
band is a little crowded. So let’s separate it by rater:
ir_rater<- matrix(item_rat, nrow = 3, byrow = TRUE) wrightMap(theta, rbind(item.par, c(rater.par, NA, NA), ir_rater), label.items = c("Items", "Raters", "Item*Raters (R1)", "Item*Raters (R2)", "Item*Raters (R3)"), axis.items = "", thr.lab.text = rbind(item.labs, rater.labs, matrix(item.labs, nrow = 3, ncol = 5, byrow = TRUE)))
Or by item:
ir_item <- matrix(item_rat, nrow = 5) wrightMap(theta, rbind(item.par, c(rater.par, NA, NA), cbind(ir_item, NA, NA)), label.items = c("Items", "Raters", "Item*Raters (I1)", "Item*Raters (I2)", "Item*Raters (I3)", "Item*Raters (I4)", "Item*Raters (I5)"), axis.items = "", thr.lab.text = rbind(item.labs, matrix(c(rater.labs, NA, NA), nrow = 6, ncol = 5, byrow = TRUE)))
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.