View source: R/local_dependence.R
| RMlocdepQ3Cutoff | R Documentation |
Q_3 Cutoff DeterminationUses parametric bootstrap simulation to determine an appropriate cutoff
value for RMlocdepQ3. Under a correctly fitting Rasch model,
Q_3 residuals have an unknown distribution; this function simulates
that distribution and returns empirical percentiles.
RMlocdepQ3Cutoff(
data,
iterations = 400,
parallel = TRUE,
n_cores = NULL,
verbose = FALSE,
seed = NULL,
cutoff_method = "hdci",
hdci_width = 0.95,
estimator = c("CML", "MML"),
dgp = c("resample", "conditional")
)
data |
A data.frame or matrix of item responses. Items must be scored starting at 0 (non-negative integers). |
iterations |
Integer. Number of simulation iterations (default 400). 400 is the calibrated floor for the Westfall-Young correction (Johansson, 2026) and the count a 95\ 1000 to 2000 for a final analysis. |
parallel |
Logical. Use parallel processing via |
n_cores |
Integer or |
verbose |
Logical. Show a progress bar (default |
seed |
Integer or |
cutoff_method |
Character. Method used to compute per-pair |
hdci_width |
Numeric in (0, 1). Width of the HDCI when
|
estimator |
Character. Estimation engine for the simulated |
dgp |
Character. Data-generating process for the parametric bootstrap.
|
The generating model is fitted once: CML item parameters (via
psychotools) and WLE person locations. For each simulation iteration,
those WLE thetas are resampled with replacement, response data are simulated
under the Rasch / Partial Credit model, the model is refitted, and Q_3
residuals are computed under estimator. The distribution of
max(Q3) - mean(Q3) across iterations provides empirical critical values.
Failed iterations (e.g., due to convergence issues) are silently discarded.
Supports both dichotomous data (simulated via psychotools::rrm()) and
polytomous data (via an internal partial credit score simulator).
Parallel processing is provided by the mirai package (optional). Install
it with install.packages("mirai") to enable parallelisation.
A list with components:
resultsdata.frame with columns mean, max, diff (one row
per successful iteration).
pair_resultsLong data.frame with columns Item1, Item2,
Q3, iteration — one row per item pair per successful iteration.
Used by RMlocdepQ3Plot.
pair_cutoffsdata.frame with per-pair cutoff summaries:
Item1, Item2, Q3_low, Q3_high. Boundaries are computed via
the method specified by cutoff_method.
actual_iterationsNumber of successful iterations.
sample_nNumber of persons used: respondents with no responses
at all (all-NA rows) are dropped, as in RMlocdepQ3;
incomplete response patterns are retained.
sample_n_totalNumber of respondents in the raw input data,
before dropping all-NA rows.
sample_has_naLogical. Whether the data contained any missing values.
sample_summarySummary statistics of estimated person parameters.
item_namesCharacter vector of item names from data.
max_diff, sd_diffMax and SD of the diff distribution.
p95, p99, p995, p999Empirical percentiles of diff.
suggested_cutoffThe 99th percentile (p99) — recommended
scalar cutoff for RMlocdepQ3.
cutoff_methodThe method used for pair_cutoffs
("hdci" or "quantile").
hdci_widthThe HDCI width used (only meaningful when
cutoff_method = "hdci").
estimatorThe estimator used for the simulated Q_3 ("CML" or
"MML"); reused by RMlocdepQ3 and
RMlocdepQ3Plot.
dgpThe data-generating process used ("resample" or
"conditional").
RMlocdepQ3
if (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)
# Few iterations for a fast example; use 500+ in real analyses
cutoff_res <- RMlocdepQ3Cutoff(sim_data, iterations = 50, parallel = FALSE,
seed = 42)
cutoff_res$suggested_cutoff # 99th percentile
# Use the cutoff in RMlocdepQ3()
RMlocdepQ3(sim_data, cutoff = cutoff_res$suggested_cutoff)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.