Saving fit, item, & person parameters from simulation replications

95 views
Skip to first unread message

cava...@gmail.com

unread,
May 16, 2016, 12:33:39 PM5/16/16
to mirt-package
Hi all,

I have a question about saving the parameters & indices from my simulation replications.  This might be more broadly a question about the apply/R functions, but I'm at a loss either way and would appreciate a pointer.

Here, I have a replication of a data set (twice, but many more in the future).  What I would like to do is access the independent analysis of each dataset and separately save the fit, item and person parameters. Preferably I would like to create a .csv file that will continually add columns per iteration to help the ease of later interpretation when I bump the iterations up to 1000. A final note would be that I'm partial to the apply group, because I will be substituting snow once all is working correctly. Any help, advice or suggestions the community could provide would be much appreciated.


MIRT<-function(x) {
  trial<<-rdply(2,simdata(a,d,1000,Theta=Theta,itemtype='graded', mins=1))
  mirtmodel<-mirt.model('
                    F1=1-15
                    F2=16-30
                    MEAN=F1,F2
                    COV=F1*F2
                    START=(1-15,a1,.5), (16-30,a2,.5)')
  Splitdata<-split(trial,trial$.n)
  Splitdata<-lapply(split(trial, trial$.n), function(d) { trial$.n <- NULL; trial }) #drops the group variable in all datasets
  MIRTmodel<-lapply(Splitdata,function(a)mirt(data=as.data.frame(Splitdata),mirtmodel,itemtype='graded',technical = list(NCYCLES = 2000)))
 
ERRORS BEGIN
  MIRTfits<<-lapply(MIRTmodel, function(b)personfit(MIRTmodel))
  results<<-lapply(MIRTmodel,function(c)mod2values(MIRTmodel))
  RMSEA<<-lapply(MIRTmodel,function(d)extract.mirt(MIRTmodel,'RMSEA'))
  pfit<<-lapply(MIRTmodel,function(e)personfit(MIRTmodel))
  m2<<-lapply(MIRTmodel,function(f)M2(MIRTmodel,technical = list(NCYCLES = 2000)))
  ifit<<-lapply(MIRTmodel,function(g)itemfit(MIRTmodel, Zh=TRUE, X2=TRUE,S_X2=TRUE))
  fscores1<<-lapply(MIRTmodel,function(h)fscores(MIRTmodel,rotate="oblimin" ,method="EAP",returnER=T))
  pfit<<-lapply(MIRTmodel,function(i)personfit(MIRTmodel))
  mdisc<<-lapply(MIRTmodel,function(j)MDISC(MIRTmodel))
  mdiff<<-lapply(MIRTmodel,function(k)MDIFF(MIRTmodel))
}

Ex. Errors include:
> ifit<<-(itemfit(MIRTmodel, Zh=TRUE, X2=TRUE,S_X2=TRUE))
Error in itemfit(MIRTmodel, Zh = TRUE, X2 = TRUE, S_X2 = TRUE) :
  trying to get slot "Data" from an object of a basic class ("list") with no slots
> results<<-lapply(MIRTmodel,function(c)mod2values(MIRTmodel))
Error in mod2values(MIRTmodel) :
  trying to get slot "ParObjects" from an object of a basic class ("list") with no slots


 

Phil Chalmers

unread,
May 19, 2016, 7:23:11 AM5/19/16
to cava...@gmail.com, mirt-package
This is very confusing to read, especially with all the <<- operators. Try organizing the code with something like the SimDesign package and report back. It will be much easier to track down at that point (and you'll be primed to run the simulation in parallel, thereby decreasing the time it takes to compute all the replications). Cheers.

Phil
--
You received this message because you are subscribed to the Google Groups "mirt-package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mirt-package...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Phil

Cavan Gray

unread,
May 26, 2016, 12:16:24 PM5/26/16
to Phil Chalmers, mirt-package
Thanks Phil, I was unaware of the simDesign package and your examples with lavaan & mirt. This should be very helpful, thanks for the recommendation & effort.
Reply all
Reply to author
Forward
0 new messages