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