Continuous: Detection of DIF for continuous item scores using linear...

View source: R/Continuous.R

ContinuousR Documentation

Detection of DIF for continuous item scores using linear regression

Description

Performs differential item functioning (DIF) detection for items with continuous responses using nested linear regression models. The procedure is an analogue of logistic-regression DIF methods for dichotomous/ordinal items, but relies on lm.

Usage

Continuous(DATA, GROUP, member.type = c("group", "cont"),
           match = "score", type = c("both", "udif", "nudif"),
           criterion = c("F", "Wald"),
           anchor = seq_len(ncol(DATA)),
           tested_items = seq_len(ncol(DATA)),
           all.cov = FALSE)

Arguments

DATA

A numeric matrix or data frame of item responses with N rows (persons) and M columns (items). Each column is treated as a continuous dependent variable.

GROUP

A vector of length N defining the membership variable. If member.type = "group", GROUP should represent two groups (e.g., a factor with two levels or a 0/1 numeric coding). If member.type = "cont", GROUP is treated as a continuous covariate and enters the model linearly.

member.type

Character string specifying the type of membership variable. "group" for a categorical grouping variable, or "cont" for a continuous membership covariate.

match

Matching variable specification passed to the internal matching builder. Common options include "score" (total score on anchor items and the tested item), "zscore" (standardized "score"), or "restscore" (total anchor score without the tested item). Matching can also be a numeric a vector of length N or a numeric matrix/data.frame with the same dimensions as Data (N \times M; each column is item-specific matching criterion).

type

Defines the DIF effect tested:

"udif"

uniform DIF only (group main effect).

"nudif"

non-uniform DIF only (interaction effect).

"both"

tests uniform and non-uniform DIF jointly.

criterion

Test criterion used to compare nested models:

"F"

nested-model F test via anova(M0, M1).

"Wald"

Wald chi-square test based on dropped coefficients.

anchor

Integer vector indicating anchor items used to build the matching variable. Default is all items.

tested_items

Integer vector indicating which items are tested for DIF. Default is all items.

all.cov

Logical; if TRUE, variance–covariance matrices of parameters for both models are returned for each tested item. Default is FALSE.

Details

For each tested item i, two nested linear models are fitted:

Full model (M1)

y ~ MATCH + GROUP + MATCH:GROUP when type = "both"
y ~ MATCH + GROUP when type = "udif"
y ~ MATCH + GROUP + MATCH:GROUP when type = "nudif",
depending on type.

Reduced model (M0)

Drops the terms corresponding to the DIF effect(s) being tested. y ~ MATCH when type = "both"
y ~ MATCH when type = "udif"
y ~ MATCH + GROUP when type = "nudif",

The test statistic is:

  • an F statistic from nested regression comparison when criterion = "F";

  • a Wald chi-square statistic when criterion = "Wald".

The change in explained variance, \Delta R^2, is computed as the difference in R^2 between M1 and M0.

Coefficient tables are mapped to fixed slots: (Intercept), MATCH, GROUP, and MATCH:GROUP, to ensure stable output even if GROUP is internally expanded (e.g., GROUP1).

Value

A list with components:

stat

Numeric vector of length M containing test statistics for each tested item (non-tested items are NA).

parM1

M \times 4 matrix of parameter estimates for full models (M1), columns (Intercept), MATCH, GROUP, MATCH:GROUP.

seM1

M \times 4 matrix of standard errors for full models (M1).

covM1

List of length M with covariance matrices for M1 (only if all.cov = TRUE).

parM0

M \times 4 matrix of parameter estimates for reduced models (M0).

seM0

M \times 4 matrix of standard errors for reduced models (M0).

covM0

List of length M with covariance matrices for M0 (only if all.cov = TRUE).

deltaR2

Numeric vector of length M giving \Delta R^2 = R^2_{M1} - R^2_{M0} for each tested item.

match

Character string describing the matching option used.

See Also

difContinuous, difLogistic.

Examples

## Toy example with continuous items
set.seed(123)
N <- 400
M <- 8

## Simulate a continuous "ability"
theta <- rnorm(N)

## Two groups
GROUP <- rep(0:1, each = N/2)

## Continuous item scores (no DIF)
DATA <- sapply(1:M, function(j){
  0.5 + 1.0 * theta + rnorm(N, sd = 1)
})

## Add uniform DIF to item 3
DATA[, 3] <- DATA[, 3] + 0.6 * GROUP

## Run Continuous DIF detection
res <- Continuous(DATA = DATA, GROUP = GROUP,
                  match = "score", type = "both",
                  criterion = "F")

res$stat
res$deltaR2

difR documentation built on Nov. 29, 2025, 9:06 a.m.