This is very nice. I am mainly using ggplot and plotly, and it is good to know that. I tried to write something more general and I do not know to what extent it may be usefull.
#' Return data for irt model plots
#' This function can handle mainly one dimensional models
#' @param model Mirt package object of irt model
#' @param type type of plot to view; can be 'info' to show the test information function, 'rxx' for the reliability function, 'infocontour' for the test information contours,
#' 'SE' for the test standard error function, 'trace', 'infotrace', and 'itemscore' for all item probability, information, and scoring or trace lines,
#' 'infoSE' for a combined test information and standard error plot, and 'score' and 'scorecontour' for the expected total score surface and contour plots.
#' If empiricalhist = TRUE was used in estimation then the type 'empiricalhist' also will be available to generate the empirical histogram plot
#' @keywords IRT
#' @export
#' @examples
#' set.seed(12345)
#' cormatrix<-data.frame(psych::sim.rasch(nvar=15,n=5000,low=-4,high=4,d=NULL,a=1,mu=0,sd=1)$items)
#' onefactormodel<-mirt::mirt(cormatrix[,1:5],1,empiricalhist=TRUE,technical=list(NCYCLES=1000000))
#' twofactormodel<-mirt::mirt(cormatrix[,1:10],2,technical=list(NCYCLES=1000000))
#' threefactormodel<-mirt::mirt(cormatrix,3,technical=list(NCYCLES=1000000))
#' data_irt(onefactormodel,"info")
#' data_irt(twofactormodel,"info")
#' data_irt(threefactormodel,"info")
#' plot_irt(onefactormodel,"info",title="Test Information",xlab=expression(theta),ylab=expression(l(theta)))
data_irt<-function(model,type) {
require(mirt)
pt<-plot(model,type=type,facet_items=FALSE)
result<-data.frame(Type=string_aes(type),pt$panel.args[[1]])
item<-rep("",nrow(result))
if(type=="trace"||type=="infotrace"||type=="itemscore"){
result$item<-factor(rep(as.character(colnames(model@Data$data)),each=50),levels=colnames(model@Data$data))
}
return(result)
}
However models with 2 and 3 θ are a bit more difficult to work with.