| RMdifGamma | R Documentation |
Computes partial gamma coefficients for Differential Item Functioning (DIF)
using iarm::partgam_DIF(). Each item is tested for association with
a single categorical DIF variable, controlling for the total score.
RMdifGamma(
data,
dif_var,
cutoff = NULL,
p_value = FALSE,
correction = c("fwer", "fdr_bh", "fdr_by", "none"),
alpha = 0.05,
output = "kable"
)
data |
A data.frame or matrix of item responses. Items must be scored
starting at 0 (non-negative integers). Missing values ( |
dif_var |
A vector (factor or character) of the same length as
|
cutoff |
Optional. Default
|
p_value |
Logical. When |
correction |
Character. Multiplicity correction for the bootstrap
p-values: |
alpha |
Numeric in (0, 1). Significance level used to flag items on
the corrected p-value. Default |
output |
Character string controlling the return value. Either
|
Partial gamma (Bjorner et al., 1998) measures the association between item response and an exogenous grouping variable, controlling for the total score. Values near 0 indicate no DIF. Recommended interpretive thresholds (Bjorner et al., 1998):
No or negligible DIF: gamma within [-0.21, 0.21], or gamma
not significantly different from 0.
Slight to moderate DIF: gamma within [-0.31, 0.31] (and outside
[-0.21, 0.21]), or not significantly outside [-0.21, 0.21].
Moderate to large DIF: gamma outside [-0.31, 0.31], and
significantly outside [-0.21, 0.21].
The iarm package must be installed (it is in Suggests, not Imports).
Bootstrap p-values. When p_value = TRUE, each item's observed
partial gamma is compared against its simulated null distribution (from
cutoff$results, where the DIF variable is random by construction). The
per-item statistic is the residual studentised by the bootstrap mean and
SD; the marginal p-value is the two-sided Monte-Carlo p-value
(1 + #\{|t*| >= |t|\}) / (B + 1), so it can be no smaller than
1 / (B + 1). correction = "fwer" uses the Westfall-Young
studentised-max step-down, which exploits the bootstrap dependence among
items (Ferreira, 2024); it is liberal when the simulation is small, so at
least 1000 iterations in RMdifGammaCutoff() are recommended (a warning
is issued below that). Unlike the asymptotic p-values from
iarm::partgam_DIF(), these are calibrated against the simulated Rasch
null rather than the asymptotic SE; they are model-conditional and
sample-size-sensitive, and are reported alongside the simulated
effect-size band, not in place of it.
If output = "kable": a knitr_kable object with columns "Item",
"Partial gamma", "SE", "Lower CI", "Upper CI", "Adj. p-value (BH)",
and "p-value sign." (a star-string indicator from
iarm::partgam_DIF()). When cutoff is provided, additional columns
"Gamma low", "Gamma high", and "Flagged" are included. With
p_value = TRUE, the asymptotic p-value columns are replaced by
bootstrap "p" and "p (adj)".
If output = "dataframe": a data.frame with columns Item, gamma,
se, lower, upper, padj_bh, Significance. When cutoff is
provided, columns gamma_low, gamma_high, and flagged are also
included. With p_value = TRUE, padj_bh and Significance are
replaced by p_gamma and padj_gamma.
The marginal p-value controls the error rate of a single comparison: for
one item (or item pair) decided on in advance it is the relevant value. But
scanning all k comparisons and flagging whichever fall below alpha tests
k hypotheses at once, so the chance of at least one false flag inflates to
roughly 1 - (1 - \alpha)^k (e.g. about 34% for k = 8 at
alpha = 0.05) – even when every marginal p-value is correctly calibrated.
The corrected (adjusted) p-value controls this: correction = "fwer" bounds
the probability of any false flag (strict, lower power), while "fdr_bh" /
"fdr_by" bound the expected proportion of false flags among those raised
(a more lenient middle ground). Rule of thumb: use the marginal p-value for a
single pre-specified comparison, and a corrected p-value when screening the
whole table – the usual workflow.
Bjorner, J. B., Kreiner, S., Ware, J. E., Damsgaard, M. T., & Bech, P. (1998). Differential item functioning in the Danish translation of the SF-36. Journal of Clinical Epidemiology, 51(11), 1189–1202. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/S0895-4356(98)00111-5")}
Ferreira, J. A. (2024). Methods of testing a 'small' or 'moderate' number of hypotheses simultaneously. Journal of Statistical Theory and Practice, 19(6). \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s42519-024-00412-4")}
Westfall, P. H., & Young, S. S. (1993). Resampling-Based Multiple Testing. Wiley.
RMdifGammaCutoff
if (requireNamespace("iarm", quietly = TRUE)) {
set.seed(42)
sim_data <- as.data.frame(
matrix(sample(0:1, 200 * 10, replace = TRUE), nrow = 200, ncol = 10)
)
colnames(sim_data) <- paste0("Item", 1:10)
dif_group <- factor(sample(c("A", "B"), 200, replace = TRUE))
# Default kable output
RMdifGamma(sim_data, dif_group)
# Return as data.frame
RMdifGamma(sim_data, dif_group, output = "dataframe")
# Simulation-based cutoffs (100 Monte-Carlo iterations)
if (requireNamespace("ggdist", quietly = TRUE)) {
cutoff_res <- RMdifGammaCutoff(sim_data, dif_var = dif_group,
iterations = 100, parallel = FALSE,
seed = 42)
RMdifGamma(sim_data, dif_group, cutoff = cutoff_res)
# Bootstrap p-values with family-wise (Westfall-Young) correction
# (use iterations >= 1000 in real analyses for stable p-values)
RMdifGamma(sim_data, dif_group, cutoff = cutoff_res, p_value = TRUE,
output = "dataframe")
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.