library(mirt)
set.seed(1234)
n <- 30
N <- 500
a <- matrix(1, n)
d <- matrix(rnorm(n), n)
group <- c(rep('reference', N), rep('focal', N*2))
## -------------
# groups completely equal
dat1 <- simdata(a, d, N, itemtype = 'dich')
dat2 <- simdata(a, d, N*2, itemtype = 'dich')
dat <- rbind(dat1, dat2)
#DIF (all other items as anchors)
SIBTEST(dat, group, focal_set = 6)
#DIF (specific anchors)
SIBTEST(dat, group, match_set = 1:5, focal_set = 6)
# DBF (all and specific anchors, respectively)
SIBTEST(dat, group, focal_set = 11:30)
SIBTEST(dat, group, match_set = 1:5, focal_set = 11:30)
#DTF
SIBTEST(dat, group, focal_set = 11:30)
SIBTEST(dat, group, match_set = 1:10) #equivalent
# different hyper pars
dat1 <- simdata(a, d, N, itemtype = 'dich')
dat2 <- simdata(a, d, N*2, itemtype = 'dich', mu = .5, sigma = matrix(1.5))
dat <- rbind(dat1, dat2)
SIBTEST(dat, group, 6:30)
SIBTEST(dat, group, 11:30)
#DIF testing with anchors 1 through 5
SIBTEST(dat, group, 6, match_set = 1:5)
SIBTEST(dat, group, 7, match_set = 1:5)
SIBTEST(dat, group, 8, match_set = 1:5)
#DIF testing with all other items as anchors
SIBTEST(dat, group, 6)
SIBTEST(dat, group, 7)
SIBTEST(dat, group, 8)
#crossed SIBTEST
SIBTEST(dat, group, 6, match_set = 1:5, cross=TRUE)
SIBTEST(dat, group, 7, match_set = 1:5, cross=TRUE)
SIBTEST(dat, group, 8, match_set = 1:5, cross=TRUE)
## -------------
## systematic differing slopes and intercepts (clear DTF)
dat1 <- simdata(a, d, N, itemtype = 'dich')
dat2 <- simdata(a + c(numeric(15), rnorm(n-15, 1, .25)), d + c(numeric(15), rnorm(n-15, 1, 1)),
N*2, itemtype = 'dich')
dat <- rbind(dat1, dat2)
SIBTEST(dat, group, 6:30)
SIBTEST(dat, group, 11:30)
#DIF testing using valid anchors
SIBTEST(dat, group, focal_set = 6, match_set = 1:5)
SIBTEST(dat, group, focal_set = 7, match_set = 1:5)
SIBTEST(dat, group, focal_set = 30, match_set = 1:5)
SIBTEST(dat, group, focal_set = 11, match_set = 1:10, cross=TRUE)
SIBTEST(dat, group, focal_set = 30, match_set = 1:15, cross=TRUE)
Run the code above in your browser using DataLab