DIF testing with dichotomous and polytomous items

272 views
Skip to first unread message

heatherleigh

unread,
Oct 10, 2023, 11:48:59 AM10/10/23
to mirt-package
Dear Phil

First of all a huge thank you for mirt and the support and materials available, it is great and has helped me so much in my phd research!

I am currently redoing some DIF analysis I previously conducted and I am encountering a new error that I hadn't faced last time I ran this on the same data. I am testing for DIF with an item set that has mostly dichotomous items and a few polytomous items (0,1,2) so I've fitted the models with itemtype = 2PL for the dichotomous items and itemtype = gpcm for poly items. 

Previously, after running a drop DIF I selected an anchor set and then for the second round of DIF testing I was running this code:
# Specify Itemtype
itemtype <- ifelse(max == 1, '2PL', 'gpcm')

# Constrained model 1 ----
conmod1 <- multipleGroup(items, 1, group=group, itemtype=itemtype,
                        invariance = c(colnames(items), 'free_means', 'free_var'))

# DIF test 1 ----
#The other items serve as the anchor items (i.e., the all-others-as-anchors model).
diftest <- DIF(conmod1, c('d','d1','d2'),
               scheme = 'drop', seq_stat = .01, p.adjust = 'fdr')

# select anchors from DIF free items in DIF test 1
# load anchor set and test set values
load("Rdata/ancset.RData") # anchor set
load("Rdata/testset.RData") # test set

# Specify a New constrained Model using Anchor Items ----
# Run model
ancmod <- multipleGroup(items, 1, group = group, itemtype = itemtype, SE=T,
                      invariance = c(ancset, 'free_means', 'free_var'))

# DIF test 2 : DIF detection LR Tests ----
diftest2 <- DIF(ancmod, c('d','d1', 'd2'), items2test = testset, p.adjust = 'fdr')
 Error in checkForRemoteErrors(val) :
  7 nodes produced errors; first error: 'i' and 'j' must not contain NA

Previously it ran with no problems, but now I am encountering an error when I run diftest2. At first I assumed it was an error is because the polytomous items didnt have a 'd' value and only have d1 and d2. So I attempted:
diftest2 <- DIF(ancmod, c('d'), items2test = testset, p.adjust = 'fdr') 
  |++++++++++++++++++++++++++++++++++++++++          | 80% ~03m 48s      Error in checkForRemoteErrors(val) :
  one node produced an error: 'i' and 'j' must not contain NA

and again encountered a similar error. Which makes me think the problem is likely to be the mix of poly and dichotmous items as there are either d or d1/d2 values marked as NA. However, I am not sure why I didn't face this error when I ran this same code a few months ago as there were still a mix of itemtypes then. 

Do I need to test the 2PL and GPCM items separately for DIF after setting the anchor?

Do you have any suggestions or ideas of what might be occurring? 

Happy to share more detailed code/data if it would be helpful. 

Thank you again for the great package and helpful forum!

Best, 
Heather 

Phil Chalmers

unread,
Oct 10, 2023, 1:24:51 PM10/10/23
to heatherleigh, mirt-package
Hi Heather,

Could you check and see whether this error exists on the current dev version (devtools::install_github('philchalmers/mirt')). If so then this is a bug that should be patched and I'll need some data + R script to reproduce the problem, though I've seen this error before and believe it was patched sometime back.

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/mirt-package/439bea57-d450-492b-aa3f-ebacebf69e8fn%40googlegroups.com.

heatherleigh

unread,
Oct 11, 2023, 6:28:05 AM10/11/23
to mirt-package
Hi Phil

Thanks so much for getting back to me so quickly.

I tried with the dev version and unfortunately it produced the same error. Please let me know what you need re:data and script and I'll send along.

Thanks again
H

heatherleigh

unread,
Oct 11, 2023, 7:41:27 AM10/11/23
to mirt-package
Hi Phil,

I've attached a script and relevant Rdata needed to run it. I've commented on the script to show the diftests that aren't running with mixed itemtypes.

Thanks so much for your support!
H

myitems.RData
testset.Rdata
group.RData
For Phil Chalmers.R
ancset.Rdata

Phil Chalmers

unread,
Oct 11, 2023, 9:30:12 AM10/11/23
to heatherleigh, mirt-package
Hi Heather,

Thanks for the reprex's, they were very helpful. I've sent a patch to the dev version to fix this issue (was a simple indexing bug). HTH!

Phil


Heather Leigh Kayton

unread,
Oct 11, 2023, 9:52:12 AM10/11/23
to Phil Chalmers, mirt-package

Hi Phil,

 

Thank you so much! Really appreciate your help with this.

 

Best,

Heather

Reply all
Reply to author
Forward
0 new messages