GuideToIRTinvarianceUsingMIRT (ANCHOR)
GuideToIRTinvarianceUsingMIRT (ANCHOR)
Contents
Getting Started.............................................................................................................................................. 2
Step 1: Testing Assumptions ......................................................................................................................... 5
Parallel analysis ......................................................................................................................................... 5
Model Fit ................................................................................................................................................... 5
Check for Sufficient Number of Category Responses ............................................................................... 5
Create a Constrained Baseline Model........................................................................................................... 6
First Round of LRTs ....................................................................................................................................... 7
Specify a New Baseline Model using Anchor Items ...................................................................................... 7
Run the Final Invariance Tests ...................................................................................................................... 8
Compute Effect Sizes .................................................................................................................................... 9
This document assumes the use of the current version of both R and R Studio. See
https://www.rstudio.com/.
2
Getting Started
To get started, there are several packages required to use this guide. If these packages are not already
installed, first run the following code:
library("psych")
library("lessR")
library("devtools")
Currently, it is best to install the developer version of the MIRT package. This will no longer be
necessary in the future.
#https://github.com/philchalmers/mirt
install_github('philchalmers/mirt')
library('mirt')
3
This step is completely optional, but I have written a function to help make it easier to identify
differentially functioning (DF) and non-DF items. Let’s go ahead and load it for later:
######################################################################
# Functions
#######################################################################
get.dif.items <- function(out.list,p.val,parms){
dif.items <- NULL
non.dif.items <- NULL
for(i in 1:length(out.list)){ # loop list of items
chi.sq <- out.list[[i]][2,6] #2 groups, so second row, and 6th column
df <- out.list[[i]][2,7]
p <- out.list[[i]][2,8]
i.name <- names(out.list[i])
d <- c(i.name,chi.sq,df,p,parms[i,])
}
if (!is.null(non.dif.items)) {
non.dif.items <- data.frame(non.dif.items, row.names = NULL)
colnames(non.dif.items)[1] <- "item"
colnames(non.dif.items)[2] <- "chi.sq"
colnames(non.dif.items)[3] <- "df"
colnames(non.dif.items)[4] <- "p"
}
r.list <- list(dif_items = dif.items, no_dif = non.dif.items)
return(r.list)
}
########################## END FUNCTIONS ########################
4
Next we will make some data for illustration purposes using a function.
########## Make the data with a lack of invariance ######
make.data <- function(N){
set.seed(1234)
a <- matrix(abs(rnorm(15,1,.3)), ncol=1)
d <- matrix(rnorm(15,0,.7),ncol=1)
d1 <- d2 <- cbind(d, d-1, d-2) # b parameters for both groups
d2[13:15, ] <- d1[13:15, ] + 1 # here is the DIF
itemtype <- rep('graded', nrow(a))
dataset1 <- simdata(a, d1, N, itemtype)
dataset2 <- simdata(a, d2, N, itemtype)
dat <- rbind(dataset1, dataset2)
return(dat)
}
N <- 1000
dat <- make.data(N)
group <- c(rep('Ref', N), rep('Foc', N))
focal.data <- dat[1:1000,]
ref.data <- dat[1001:2000,]
Here we have specified our sample size per group and given the groups labels. In general, you want your
reference group to be the first group.
5
Model Fit
Next, compute stat and examine plots.
########## check model fit ##############
foc.model <- mirt(focal.data, model = 1, itemtype = "graded", SE=TRUE)
M2(foc.model)
ref.model <- mirt(ref.data, model = 1, itemtype = "graded", SE=TRUE)
M2(ref.model)
foc.fit <- itemfit(foc.model)
foc.fit
ref.fit <- itemfit(ref.model)
ref.fit
$no_dif
item chi.sq df p a1 d1 d2 d3
1 Item_2 5.308 4 0.2571 1.094 -0.452 -1.527 -2.548
2 Item_4 1.156 4 0.8853 0.231 -0.579 -1.598 -2.739
3 Item_8 5.054 4 0.2818 0.904 -0.471 -1.56 -2.577
4 Item_9 6.721 4 0.1514 0.754 0.269 -0.782 -1.768
5 Item_10 7.881 4 0.096 0.652 -0.563 -1.502 -2.445
6 Item_12 7.985 4 0.0921 0.68 0.333 -0.657 -1.745
The above runs the model and also requests the parameters.
8
Check out the output. Looks like the correct items were detected.
> dif.anchor.out
$dif_items
item chi.sq df p a1 d1 d2 d3
1 Item_13 94.622 4 0 0.753 0.342 -0.71 -1.697
2 Item_14 84.691 4 0 0.656 -0.502 -1.442 -2.386
3 Item_15 64.678 4 0 0.719 -1.018 -1.939 -2.953
$no_dif
item chi.sq df p a1 d1 d2 d3
1 Item_1 7.514 4 0.1111 0.737 -0.01 -1.045 -1.976
2 Item_3 2.072 4 0.7225 1.288 -0.605 -1.655 -2.488
3 Item_4 1.114 4 0.892 0.274 -0.562 -1.617 -2.75
4 Item_5 3.916 4 0.4175 1.204 1.645 0.702 -0.426
5 Item_6 2.661 4 0.6161 1.287 0.067 -0.968 -2.036
6 Item_7 2.484 4 0.6475 0.832 -0.325 -1.366 -2.262
7 Item_11 3.511 4 0.4762 0.91 -0.386 -1.477 -2.496
9
And the ETS plot. Item plots are also output but not presented here.