philchalmers / mirt

Multidimensional item response theory
199 stars 75 forks source link

itemfit gives "Error in log_itemtrace * fulldata : non-conformable arrays" #227

Closed jbuncher closed 2 years ago

jbuncher commented 2 years ago

I'm trying to use the itemfit command to get the infit and outfit statistics for Rasch models that come out of multiple uses multipleGroup() (i.e., MG1 compares groups A & B, MG2 compares groups A & C, etc.).

For some of the comparisons, when running itemfit(MG#, na.rm = TRUE, fit_stats = 'infit', method = 'ML'), it returns the error "Error in log_itemtrace * fulldata : non-conformable arrays". If fit_stats = 'infit' is omitted, the function returns the S_X2, df.S_X2, RMSEA.S_X2, and p.S_X2 stats without issue.

I tried going through the documentation, and I didn't see anything (obvious) on using itemfit to extract these parameters from a multipleGroup() object. I figure the issue is one of the following:

1.) I am not using the mutlipleGroup() & itemfit() functions together correctly, in which case guidance/assistance would be appreciated! 2.) Something about how I am constructing the groups themselves is amiss, but it's not clear to me why it would work for 2 of the 9 comparisons I'm trying to make and not the other 7 (I don't see any obvious similarities between the 2 it works for and the 7 it doesn't). 3.) The "nonconformable array" error means that there's a matrix multiplication issue in line 527 of itemfit.R, where "" should be replaced by "%%". Then again, I don't know if "log_itemtrace" and "fulldata" are meant to be matrices, so this is conjecture on my part. (Edit: Markdown is misbehaving, but "asterisk" should be replaced by %asterisk%)

Any help/response is greatly appreciated!

philchalmers commented 2 years ago

It's hard to know what the problem is without some type of reproduceable example, though I suspect it could be related to some type of missing data problem. Could you construct a simple one and send it my way (data + R script)? That way I can reproduce the issue on my end, and if it's a bug I could try to make a patch. Thanks.

jbuncher commented 2 years ago

Sure thing. I'm attaching a zipped script (github didn't want me to attach the .R file), but can I send you the datafile on a non-public channel? I've anonymized it, but still don't want it "public". Edit - Original file attached was empty, this one should be correct. TroubleShootScript.R.zip

.

philchalmers commented 2 years ago

Yes, just send the data to my gmail address. Once I'm finished with the data I'll delete it from my drive.

jbuncher commented 2 years ago

Following up on this since it's been a while - Did you receive the data file I sent (May 25th)? Just want to make sure you're not waiting on me for anything.

philchalmers commented 2 years ago

This issue was tricky to track down, though I found that it was related to the recent na.rm flag support to deal with unsupported missing data vectors in post-convergence statistics. For multiple group objects this was incorrect in some cases, such as yours, but has now been patched (your script runs fine on my end with no warning messages). Thanks for the report and your patience.