This code uses the example data from the workshop. First we fit the model and plot some item level functions discussed in the workshop.
# Load data and separate depression itemscint <-read.csv("cint_data.csv")depression_names <-c("cint1", "cint2", "cint4", "cint11", "cint27", "cint28", "cint29", "cint30")depression_items <- cint[, depression_names]# Run GRM model (use SE = T in mirt call to get SEs)grm <-mirt(depression_items, itemtype ="graded",verbose = F) # to omit iteration history in output# Parameter estimatescoef(grm, IRTpars = T, simplify = T)
# Per item plots itemplot(grm, item =1, type ="threshold", main ="Cumulative response functions")
itemplot(grm, item =1, type ="trace", main ="Category response functions")
# Plotting all test items plot(grm, type ="itemscore", main ="Expected item score functions", facet = F)
Next, consider the IIFs, TIF, Reliability of the depression items
# Item infoplot(grm,type ="infotrace", main ="Item information functions", facet = F)
# Test infoplot(grm,type ="info", main ="Item information functions", facet = F)
plot(grm,type ="rxx", main ="Item information functions", facet = F)
marginal_rxx(grm)
[1] 0.7944443
DIF analysis with GRM
Likelihood ratio based DIF testing with the GRM model. Step 1 is to estimate the multigroup model with strong / strict invariance constraints.
# Groups need to be a factor gender <-factor(cint$cfemale)# Invariance constraints used by mirtstrong.invariance <-c("free_mean", "free_var", "slopes", "intercepts")# Estimate modelstrong.mod <-multipleGroup(depression_items, group = gender, itemtype ="graded",invariance = strong.invariance,verbose = F)# View output (item parms the same in both groups?)coef(strong.mod, IRTpars = T, simplify = T)
As shown above, we conclude the last two items exhibit DIF (without purification). With purification, we get the same conclusion, but the output is only shown for items that exhibited DIF
DIF(strong.mod, which.par =c("a1", "d1", "d2", "d3"), scheme ="drop_sequential", #<- different schemeseq_stat = .05, # <- Type I Error rate for DIFmax_run =2) # <- two stages only
Checking for DIF in 6 more items
Computing final DIF estimates...
After a DIF analysis, we may wish to better understand how DIF affects items. This can be done using the partial invariance model in which items without DIF are constrained over groups and items with DIF are estiamted freely over groups.
# Invariance constraintspartial.invariance <-c("free_mean", "free_var", "cint1", "cint2", "cint4", "cint27", "cint28")# Estimate modelpartial.mod <-multipleGroup(depression_items, group = gender, itemtype ="graded",invariance = partial.invariance,verbose = F)# Plot IRFs of biased itemsitemplot(partial.mod, type ="score", item ="cint29", main ="CINT 29")
itemplot(partial.mod, type ="score", item ="cint30", main ="CINT 30")
We can see that item 29 is biased “towards” females and item 30 is biased towards males. Based on the estimate of group mean differences in the strong (.478) and partial model (.418), it is unclear if DIF may be affecting conclusions about how the groups differ. More on this in part 3 of the workshop.