项目功能差异DIF
计算公式
符号
| 符号 | 含义 |
|---|---|
| yj | 第 j 题的作答(0/1) |
| Rj | 去掉第 j 题后其余题合计分(rest score) |
| G | 组别变量(0/1) |
| β0–β3 | logistic 回归系数 |
| n | 样本量 |
| Lm | 第 m 个 logistic 模型的似然 |
| L0 | 仅含常数项模型的似然 |
| as、bs、cs、ds | 第 s 层 2×2 表的四格频数 |
| ns | 第 s 层样本量 |
| E(as)、Var(as) | 第 s 层四格频数在超几何分布下的期望与方差 |
| ORMH | Mantel–Haenszel 共同优势比 |
| Δ | MH 效应量 |
核心公式
公式 (1.1):三个嵌套 logistic 模型
\[
\begin{aligned}\mathrm{M1:}\quad &\operatorname{logit}P(y_j=1)=\beta_0+\beta_1R_j\\ \mathrm{M2:}\quad &\operatorname{logit}P(y_j=1)=\beta_0+\beta_1R_j+\beta_2G\\ \mathrm{M3:}\quad &\operatorname{logit}P(y_j=1)=\beta_0+\beta_1R_j+\beta_2G+\beta_3R_jG\end{aligned}
\]
公式 (1.2):均匀与非均匀 DIF 的似然比检验
\[
\chi_U^2=2\left(\ln L_2-\ln L_1\right),\qquad \chi_{NU}^2=2\left(\ln L_3-\ln L_2\right),\qquad \mathrm{df}=1
\]
公式 (1.3):Nagelkerke 效应量
\[
R_N^2=\frac{1-\exp\left[2\left(\ln L_0-\ln L_m\right)/n\right]}{1-\exp\left(2\ln L_0/n\right)}
\]
公式 (1.4):Mantel–Haenszel 优势比与检验
\[
\mathrm{OR}_{MH}=\frac{\sum_s a_sd_s/n_s}{\sum_s b_sc_s/n_s},\qquad \chi_{MH}^2=\frac{\left(\left|\sum_s a_s-\sum_s E(a_s)\right|-0.5\right)^2}{\sum_s \operatorname{Var}(a_s)},\qquad \Delta=-2.35\ln \mathrm{OR}_{MH}
\]
参考文献
- Zumbo, B. D. (1999). A Handbook on the Theory and Methods of Differential Item Functioning (DIF). Directorate of Human Resources Research and Evaluation, National Defense Headquarters.
- Holland, P. W., & Thayer, D. T. (1988). Differential item performance and the Mantel–Haenszel procedure. In H. Wainer & H. I. Braun (Eds.), Test Validity (pp. 129–145). Lawrence Erlbaum.
- Magis, D., Béland, S., Tuerlinckx, F., & De Boeck, P. (2010). A general framework and an R package for the detection of dichotomous differential item functioning. Behavior Research Methods, 42(3), 847–862.
算法参数
本方法没有需要额外选择的算法参数:变量的选择属于分析设置,全部计算按上式的定义直接完成。
验证报告
数据与 R 包
提示词
以 G 为组别变量,对 Y1–Y6 六个二分类题逐题做 DIF 检验,给出均匀与非均匀 DIF 的 LR χ²、p 值、ΔR² 和 ETS 等级,以及 MH-DIF 的 OR、χ² 与 ETS 等级。
R 代码
library(difR)
d <- read.csv("dif.csv")
items <- d[, paste0("Y", 1:6)]
out <- data.frame(item = names(items))
for (j in 1:6) {
rest <- rowSums(items) - items[, j]
u <- difLogistic(items[, j, drop = FALSE], group = d$G, focal.name = 1,
type = "udif", match = rest)
n <- difLogistic(items[, j, drop = FALSE], group = d$G, focal.name = 1,
type = "nudif", match = rest)
mh <- difMH(items[, j, drop = FALSE], group = d$G, focal.name = 1,
match = rest)
out$chi_u[j] <- u$Logistik
out$p_u[j] <- u$p.value
out$chi_n[j] <- n$Logistik
out$p_n[j] <- n$p.value
out$MH[j] <- mh$MH
out$p_MH[j] <- mh$p.value
}
print(out, digits = 15)
对比结果
| 指标 | SPSSAU | R | 差值 |
|---|---|---|---|
| 均匀 χ²(Y1) | 0.0018378721 | 0.0018378721 | 1.1e−11 |
| 均匀 p(Y1) | 9.658048e−1 | 9.658048e−1 | 9.64e−12 |
| 均匀 χ²(Y2) | 5.2852851879 | 5.2852851879 | 3.42e−11 |
| 均匀 p(Y2) | 2.150637e−2 | 2.150637e−2 | 4.15e−10 |
| 均匀 χ²(Y3) | 7.4015576301 | 7.4015576301 | 4.75e−11 |
| 均匀 p(Y3) | 6.516742e−3 | 6.516743e−3 | 2.46e−9 |
| 均匀 χ²(Y4) | 0.1699395866 | 0.1699395866 | 4.27e−11 |
| 均匀 p(Y4) | 6.801655e−1 | 6.801655e−1 | 5.83e−12 |
| 均匀 χ²(Y5) | 0.6283844080 | 0.6283844080 | 4.54e−11 |
| 均匀 p(Y5) | 4.279485e−1 | 4.279485e−1 | 8.14e−12 |
| 均匀 χ²(Y6) | 0.1532701640 | 0.1532701640 | 2.71e−11 |
| 均匀 p(Y6) | 6.954297e−1 | 6.954297e−1 | 9.82e−12 |
| 非均匀 χ²(Y3) | 2.7247489016 | 2.7247489016 | 4.44e−11 |
| 非均匀 p(Y3) | 9.880366e−2 | 9.880366e−2 | 1.56e−10 |
| MH χ²(Y3) | 6.3061510090 | 6.3061510090 | 2.16e−11 |
| MH p(Y3) | 1.203198e−2 | 1.203198e−2 | 1.66e−9 |
结论:以 rest score 为匹配变量逐题拟合时,六题的均匀 LR χ² 与 p、Y3 的非均匀 LR χ² 与 p、Y3 的 MH χ² 与 p 均与 difR 一致;表中差值在 10 位小数舍入量级(约 1e−11)。difR 默认用总分匹配并输出 2 自由度的联合检验;R 改为逐题 rest score 加均匀/非均匀分型,以对齐 SPSSAU 的口径。
引用SPSSAU. 项目功能差异DIF:计算公式与参数[EB/OL]. SPSSAU算法手册, 2026-11-20. https://www.spssau.com/algorithm/psychometrics/dif.html.