pairwiseDIF: Pairwise post hoc DIF analysis

View source: R/pairwiseDIF.R

pairwiseDIFR Documentation

Pairwise post hoc DIF analysis

Description

Conduct pairwise Wald follow-up tests after omnibus DIF analysis with three or more groups. This function can also be used for DIF detection based on the Wald test by specifying the studied (potentially DIF) items and anchor items manually.

The input can be a dif object returned by dif(), in which case DIF items are selected using adjusted omnibus p-values, or raw data plus user-specified DIF items and anchor items.

For DIF detection, the data are rearranged so that anchor items appear once and DIF items are duplicated once for each observed group. For example, if Item 3 is flagged as DIF in a three-group analysis and Items 1 and 2 are not, the refit is arranged as Item 1, Item 2, Item 3 (Group 1), Item 3 (Group 2), and Item 3 (Group 3).

The Wald test is used for comparison of item parameters across all pairs of groups for each DIF item. The p-values are adjusted for multiple comparisons.

The returned object stores this mapping in posthoc.rearrangement, which records the refit position, original item number, item label, item type, and group label for each row of the posthoc GDINA calibration. plot() function can be used to draw grouped bar chart for DIF items.

Usage

pairwiseDIF(
  object = NULL,
  dat = NULL,
  Q = NULL,
  group = NULL,
  model = "GDINA",
  sequential = FALSE,
  dif.items = NULL,
  anchor.items = NULL,
  alpha.level = 0.05,
  p.adjust.methods = "holm",
  SE.type = NULL,
  ...
)

Arguments

object

an object returned by dif().

dat

item responses from two or more groups; missing data need to be coded as NA.

Q

Q-matrix specifying the association between items and attributes.

group

a factor or a vector indicating the group each individual belongs to.

model

model for each item.

sequential

Logical; whether a sequential model is fit to the data. Default is FALSE.

dif.items

which items are subject to pairwise DIF follow-up.

anchor.items

optional anchor items. If omitted, all non-DIF items are treated as shared across groups.

alpha.level

adjusted omnibus p-value cutoff used to flag DIF items when object is supplied.

p.adjust.methods

adjusted p-values for pairwise Wald tests within each item.

SE.type

Type of standard error estimation methods for the Wald test.

...

arguments passed to GDINA() for the final post hoc refit.

Value

A pairwiseDIF object with key elements including:

  • test: a data frame of pairwise Wald test results with columns for item, group pair, Wald statistic, degrees of freedom, raw p-value, and adjusted p-value.

  • dif.items: numeric indices of items included in pairwise DIF follow-up.

  • anchor.items: numeric indices of items treated as shared (non-DIF) in the final post hoc refit.

  • group.labels: observed group labels used in pairwise comparisons.

  • posthoc.rearrangement: a data frame describing how original items were rearranged for refit (refit position, original item number, item label, item type, and group information).

  • posthoc.fit: the fitted GDINA object from the final post hoc calibration.

  • posthoc.config: the internal item/group configuration aligned with the refit design matrix.

Author(s)

Wenchao Ma, The University of Minnesota, wma@umn.edu

See Also

dif

Examples

## Not run: 

set.seed(123456)
N <- 500
Q <- sim30GDINA$simQ
gs <- matrix(.2,ncol = 2, nrow = nrow(Q))
# By default, individuals are simulated from uniform distribution
# and deltas are simulated randomly
sim1 <- simGDINA(N,Q,gs.parm = gs,model="DINA")
sim2 <- simGDINA(N,Q,gs.parm = gs,model=c(rep("DINA",nrow(Q)-1),"DINO"))
sim3 <- simGDINA(N,Q,gs.parm = gs,model="DINA")
dat <- rbind(extract(sim1,"dat"),extract(sim2,"dat"),extract(sim3,"dat"))
gr <- rep(c("G1","G2","G3"),each=N)

# DIF using Wald test - omnibus test
dif.wald <- dif(dat, Q, group=gr, method = "Wald")
dif.wald
# pairwise comparison between all pair of groups
dif.pair = pairwiseDIF(dif.wald)
dif.pair
# draw plot to show the DIF
plot(dif.pair, withSE = TRUE)

## End(Not run)

GDINA documentation built on Oct. 6, 2026, 1:07 a.m.