| RMdifGammaCutoff | R Documentation |
Uses parametric bootstrap simulation to determine appropriate cutoff values
for partial gamma DIF analysis via partgam_DIF. Under
a correctly fitting Rasch model where the DIF variable is unrelated to item
responses (i.e., no true DIF), this function generates the expected
distribution of absolute partial gamma values per item, providing empirical
critical values.
RMdifGammaCutoff(
data,
dif_var,
iterations = 250,
parallel = TRUE,
n_cores = NULL,
verbose = FALSE,
seed = NULL,
cutoff_method = "hdci",
hdci_width = 0.99
)
data |
A data.frame or matrix of item responses. Items must be scored
starting at 0 (non-negative integers). Only complete cases (rows without
any |
dif_var |
A vector (factor, character, or integer) defining group
membership for DIF analysis. Must have the same length as |
iterations |
Integer. Number of simulation iterations (default 250). |
parallel |
Logical. Use parallel processing via |
n_cores |
Integer or |
verbose |
Logical. Show a progress bar (default |
seed |
Integer or |
cutoff_method |
Character string specifying how cutoff intervals are
computed. Either |
hdci_width |
Numeric. Width of the HDCI when |
For each simulation iteration the function:
Resamples person parameters (thetas) with replacement from the WLE person locations.
Simulates item response data under a Rasch model (dichotomous via
psychotools::rrm() or polytomous via an internal partial credit
simulator).
Creates a random DIF variable by sampling group labels with the
same proportions as the observed dif_var, so there is no true DIF
by construction.
Computes partial gamma DIF statistics via
iarm::partgam_DIF().
The distribution of partial gamma values across iterations provides empirical critical values per item. Values from real data that fall outside these bounds suggest DIF that exceeds what would be expected by chance under a correctly fitting Rasch model. Failed iterations (e.g., due to convergence issues or degenerate data) are silently discarded.
The generating model uses CML item thresholds via psychotools::pcmodel()
(a dichotomous item is a 2-category PCM) and WLE person locations,
consistent with the rest of the package; responses are simulated with
psychotools::rrm() (dichotomous) or an internal partial credit score
simulator (polytomous).
Parallel processing is provided by the mirai package (optional). Install
it with install.packages("mirai") to enable parallelisation.
The iarm package must be installed (it is in Suggests, not Imports).
A list with components:
resultsdata.frame with columns iteration, Item, and
gamma (one row per item per successful iteration).
item_cutoffsdata.frame with per-item cutoff summaries: Item,
gamma_low, gamma_high. Bounds are computed using the method
specified by cutoff_method.
actual_iterationsNumber of successful iterations.
sample_nNumber of complete cases used.
sample_n_totalNumber of respondents in the raw input data,
before removing rows with NA in data or dif_var.
sample_has_naLogical. Whether data or dif_var contained
any missing values.
sample_summarySummary statistics of estimated person parameters.
item_namesCharacter vector of item names from data.
dif_group_sizesNamed integer vector of group sizes used in the
simulation (matches proportions in the observed dif_var).
cutoff_methodThe method used to compute cutoffs ("hdci" or
"quantile").
hdci_widthThe HDCI width used (only meaningful when
cutoff_method = "hdci").
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")}
Henninger, M., Radek, J., Debelak, R., & Strobl, C. (2025). Partial credit trees meet the partial gamma coefficient for quantifying DIF and DSF in polytomous items. Behaviormetrika, 52, 221–257. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s41237-024-00252-3")}
partgam_DIF
if (requireNamespace("iarm", quietly = TRUE) &&
requireNamespace("ggdist", 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_sex <- sample(c("male", "female"), 200, replace = TRUE)
# Run 100 iterations sequentially for a quick demo
cutoff_res <- RMdifGammaCutoff(sim_data, dif_var = dif_sex,
iterations = 100, parallel = FALSE,
seed = 42)
cutoff_res$item_cutoffs
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.