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(...)

Arguments

N.sim

Integer. Number of Monte Carlo simulations to run. Default is 500.

sample

Integer. Sample size per simulation (number of respondents).

prevalence

Numeric. True prevalence rate of the sensitive attribute (between 0 and 1).

p

Numeric. Probability for the randomization item in sensitive question (between 0 and 1).

p.prime

Numeric. Probability for the anchor question (non-sensitive, between 0 and 1).

gamma

Numeric. Proportion of attentive respondents (between 0 and 1).

direct

Numeric. Direct questioning estimate for comparison purposes (between 0 and 1).

verbose

Logical. If `TRUE` (the default), display a progress bar while simulations run.

...

Arguments passed to sim_cwdata().

Value

A list containing:

Results

Named vector with summary statistics including average bias, RMSE, and coverage rates for both naive and bias-corrected estimators

BiasCorrectEst

Numeric vector of bias-corrected point estimates (sorted)

BiasCorrectLow

Numeric vector of lower bounds of 95% bootstrap CIs (sorted)

BiasCorrectHigh

Numeric vector of upper bounds of 95% bootstrap CIs (sorted)

EstimatedBias

Numeric vector of estimated bias values for each simulation

RelativeLengthCI

Numeric vector of relative CI lengths (bias-corrected vs naive)

Details

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.

References

Atsusaka and Stevenson (2023). Appendix C5: Sample Size Determination and Parameter Selection. doi:10.1017/pan.2021.43 .

Examples

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)
} # }