DIF_test: Test for differential item functioning (DIF)

View source: R/mirt.R

DIF_testR Documentation

Test for differential item functioning (DIF)

Description

Tests are done following the mirt package approach outlined by Chalmers.

Usage

DIF_test(
  items,
  model,
  group,
  fscores_pars = list(full.scores = T, full.scores.SE = T),
  messages = T,
  method = "EM",
  technical = list(),
  itemtype = NULL,
  verbose = T,
  DIF_args = NULL,
  multiple_testing_method = "bonferroni",
  ...
)

Arguments

items

Item data to use

model

Item model

group

Group (2 groups at most)

fscores_pars

Any extra scoring parameters used

messages

Show messages

method

Method

technical

Further technical args to pass to mirt

itemtype

Item type

verbose

Verbose output

DIF_args

Arguments to pass to mirt::DIF

multiple_testing_method

Method to use for multiple testing correction, see p.adjust(). Default is "bonferroni"

...

Other arguments passed to mirt functions

Value

A list of results

Examples

library(mirt)
n = 1000
n_items = 10

#slopes
set.seed(1)
a1 = runif(n_items, min = .5, max = 2)
a2 = a1
a2[1] = 0 #item doesnt work for this group
#intercepts
i1 = rnorm(n_items, mean = -0.5, sd = 2)
i2 = i1
i2[2] = -2 #item much harder for this group

#simulate data twice
d1 = simdata(
a1,
i1,
N = n,
itemtype = "2PL",
mu = 0
)

d2 = simdata(
a2,
i2,
N = n,
  itemtype = "2PL",
  mu = 1
)

#combine
d = rbind(
  d1 %>% set_names("item_" + 1:n_items),
  d2 %>% set_names("item_" + 1:n_items)
) %>% as.data.frame()

#find the bias
DIF_results = DIF_test(d, model = 1, itemtype = "2PL", group = rep(c(1, 2), each = n))
DIF_results$effect_size_items$conservative
plot(DIF_results$fits$anchor_conservative)
plot(DIF_results$fits$anchor_conservative, type = "trace")

Deleetdk/kirkegaard documentation built on April 27, 2024, 3:26 p.m.