Search code examples
rggplot2plotlatticelikert

Trying to find a way to combine IRT info plots from 3 different mirt models in R in the same


I am looking to combine all three" test information function" lines (one for each model) into one and the same graph. I have a data set of category 1-5 Likert responses in 400 rows in sets of 8 columns (one for each item). I have ran three IRT models on these sets using mirt package in R, and produced test info plots. I would like to combine IRT test info plots from three different (graded response) models, three lines, in one and the same grid.

plot(PFgrmodel29, type = 'info', xlim = c(-4, 4), ylim=c(0,85)) 
plot(PFgrmodel43, type = 'info', xlim = c(-4, 4), ylim=c(0,85)) 
plot(PFgrmodel57, type = 'info', xlim = c(-4, 4), ylim=c(0,85))

Example of test info plot: Example of test info plot

How can I achieve this with mirt, lattice, ggplot2 or similar?


Solution

  • Your plots from the mirt package are a lattice object, so you can try using latticeExtra, since you did not provide your dataset, I provide an example code below using the example dataset in the package:

    library(mirt)
    library(latticeExtra)
    
    fulldata <- expand.table(LSAT7)
    mod1 <- mirt(fulldata,1,SE=TRUE)
    mod2 <- mirt(fulldata,1, itemtype = 'Rasch')
    mod3 <- mirt(fulldata,1,itemtype='ideal')
    
    key=list(columns=2, 
            text=list(lab=c("mod1","mod2","mod3")), 
            lines=list(lwd=4, col=c("blue","orange","red"))
    )
    
    p1 = plot(mod1,type="info",key=key)
    p2 = update(plot(mod2,type="info"),col="orange")
    p3 = update(plot(mod3,type="info"),col="red")
    p1+p2+p3
    

    enter image description here