Core simulation function that generates crosswise model data with inattentive respondents and computes bias-corrected prevalence estimates with bootstrap confidence intervals. This implements the methodology described in Appendix C5 for power analysis of the crosswise model.
sim_cwdata(
N.sim = 500,
sample,
prevalence,
p,
p.prime,
gamma,
direct,
verbose = TRUE
)
sim.cwdata(...)Integer. Number of Monte Carlo simulations to run. Default is 500.
Integer. Sample size per simulation (number of respondents).
Numeric. True prevalence rate of the sensitive attribute (between 0 and 1).
Numeric. Probability for the randomization item in sensitive question (between 0 and 1).
Numeric. Probability for the anchor question (non-sensitive, between 0 and 1).
Numeric. Proportion of attentive respondents (between 0 and 1).
Numeric. Direct questioning estimate for comparison purposes (between 0 and 1).
Logical. If `TRUE` (the default), display a progress bar while simulations run.
Arguments passed to sim_cwdata().
A list containing:
Named vector with summary statistics including average bias, RMSE, and coverage rates for both naive and bias-corrected estimators
Numeric vector of bias-corrected point estimates (sorted)
Numeric vector of lower bounds of 95% bootstrap CIs (sorted)
Numeric vector of upper bounds of 95% bootstrap CIs (sorted)
Numeric vector of estimated bias values for each simulation
Numeric vector of relative CI lengths (bias-corrected vs naive)
The function implements the crosswise model with bias correction for inattentive respondents. For each simulation:
Generates attentive/inattentive status based on gamma
Simulates responses to sensitive question (crosswise format)
Simulates responses to anchor question (for estimating attention rate)
Computes naive crosswise estimate
Applies bias correction based on estimated inattention
Uses bootstrap (500 iterations) to compute 95% confidence intervals
The bias correction formula is: $$\hat{\pi}_{BC} = \hat{\pi}_{naive} - \hat{Bias}$$ where the bias is estimated using the anchor question responses.
Atsusaka and Stevenson (2023). Appendix C5: Sample Size Determination and Parameter Selection. doi:10.1017/pan.2021.43 .
if (FALSE) { # \dontrun{
# Basic usage
result <- sim_cwdata(
N.sim = 100,
sample = 500,
prevalence = 0.1,
p = 0.1,
p.prime = 0.1,
gamma = 0.8,
direct = 0.05
)
print(result$Results)
} # }