Uses 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.
Arguments
- 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 500).
- parallel
Logical. Use parallel processing via
miraiif available (defaultTRUE).- n_cores
Integer or
NULL. Number of parallel workers. WhenNULL,getOption("mc.cores")is checked first. If neither is set andparallel = TRUE, a warning is issued and execution falls back to sequential (single core) processing.- verbose
Logical. Show a progress bar (default
FALSE).- seed
Integer or
NULL. Random seed for reproducibility.- cutoff_method
Character. Method used to compute per-pair \(Q_3\) credible intervals in
pair_cutoffs. One of"hdci"(the default, Highest Density Continuous Interval viaggdist::hdci()) or"quantile"(symmetric 2.5th / 97.5th percentiles). Only affectspair_cutoffs; the global$suggested_cutoff(99th percentile ofmax(Q3) - mean(Q3)) is unaffected.- hdci_width
Numeric in (0, 1). Width of the HDCI when
cutoff_method = "hdci". Default0.99. Ignored whencutoff_method = "quantile".- estimator
Character. Estimation engine for the simulated \(Q_3\) values, passed through to the per-iteration computation.
"CML"(default) uses CML item parameters and WLE person locations;"MML"usesmirt. This must match theestimatorlater given toRMlocdepQ3; the value is stored in the returned object's$estimatorand reused automatically.- dgp
Character. Data-generating process for the parametric bootstrap.
"resample"(default) draws person locations by resampling the WLE estimates with replacement and simulates responses under the model – a marginal null."conditional"instead simulates each respondent's pattern from the exact Rasch conditional distribution given their observed total score (and answered items), with item parameters fixed – a conditional null that fixes the score margin and needs no latent distribution, avoiding the over-dispersion of resampled point estimates. The two give different cut-offs; see the package's comparison study. Experimental.
Value
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 byRMlocdepQ3Plot.pair_cutoffsdata.frame with per-pair cutoff summaries:
Item1,Item2,Q3_low,Q3_high. Boundaries are computed via the method specified bycutoff_method.actual_iterationsNumber of successful iterations.
sample_nNumber of persons used: respondents with no responses at all (all-
NArows) are dropped, as inRMlocdepQ3; incomplete response patterns are retained.sample_n_totalNumber of respondents in the raw input data, before dropping all-
NArows.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
diffdistribution.p95,p99,p995,p999Empirical percentiles of
diff.suggested_cutoffThe 99th percentile (
p99) — recommended scalar cutoff forRMlocdepQ3.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 byRMlocdepQ3andRMlocdepQ3Plot.dgpThe data-generating process used (
"resample"or"conditional").
Details
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.
Examples
# \donttest{
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)
}
#>
#>
#> Table: Dynamic cut-off: 0.112 (mean Q3 -0.11 + 0.222). Correlations exceeding the cut-off may indicate local dependence; see the per-pair table for detail. n = 200 respondents.
#>
#> | |Item1 |Item2 |Item3 |Item4 |Item5 |Item6 |Item7 |Item8 |Item9 |Item10 |above_cutoff |
#> |:------|:-----|:-----|:-----|:-----|:-----|:-----|:-----|:-----|:-----|:------|:------------|
#> |Item1 | | | | | | | | | | | |
#> |Item2 |-0.02 | | | | | | | | | | |
#> |Item3 |-0.17 |-0.2 | | | | | | | | | |
#> |Item4 |-0.13 |-0.2 |-0.1 | | | | | | | | |
#> |Item5 |-0.19 |-0.06 |-0.02 |-0.12 | | | | | | | |
#> |Item6 |-0.1 |-0.1 |-0.17 |0.03 |-0.19 | | | | | | |
#> |Item7 |-0.17 |-0.13 |-0.07 |0.03 |-0.04 |-0.11 | | | | | |
#> |Item8 |-0.03 |-0.06 |-0.11 |-0.28 |-0.05 |-0.16 |-0.18 | | | | |
#> |Item9 |-0.03 |-0.08 |-0.16 |-0.19 |-0.22 |-0.03 |-0.1 |-0.02 | | | |
#> |Item10 |-0.16 |-0.14 |0 |-0.09 |-0.1 |-0.18 |-0.15 |-0.12 |-0.09 | | |
# }