Skip to contents

Wraps list::ict.test() to compute p-values for the null hypothesis of no design effect in a list experiment – i.e., that responses to the non-sensitive items do not depend on treatment status. The underlying test uses Monte Carlo simulation and returns the Bonferroni-corrected minimum p-value across several moment conditions.

This function can be applied to:

  • the whole sample (when cohorts = NULL),

  • a single cohort (tibble with id and weight),

  • a cohort_set (nested tibble with a list-column cohort).

Cohort weights are used only to define membership (rows with a matching id); the design-effect test itself is unweighted because list::ict.test() does not support survey weights.

Usage

lx_design_effect(
  data,
  cohorts = NULL,
  alpha = 0.05,
  n.draws = 250000,
  gms = TRUE
)

# S3 method for class '`NULL`'
lx_design_effect(
  data,
  cohorts = NULL,
  alpha = 0.05,
  n.draws = 250000,
  gms = TRUE
)

# S3 method for class 'character'
lx_design_effect(data, cohorts, alpha = 0.05, n.draws = 250000, gms = TRUE)

# S3 method for class 'cohort'
lx_design_effect(data, cohorts, alpha = 0.05, n.draws = 250000, gms = TRUE)

# S3 method for class 'cohort_set'
lx_design_effect(data, cohorts, alpha = 0.05, n.draws = 250000, gms = TRUE)

Arguments

data

A data frame containing at least:

  • private: numeric list-experiment outcome,

  • treatment: factor/character with level "treatment" for treated units,

  • an "n_insens" attribute giving the number of non-sensitive items (passed as J to list::ict.test()). It must also contain an id column when cohorts is not NULL.

cohorts

A cohort, cohort_set, NULL for the whole population, "predictors" (all predictors + population), "population" (population-only), or a character vector of predictor names. Include "population" in an explicit vector when you also want the overall population cohort.

alpha

Confidence level for the statistical test.

n.draws

Number of Monte Carlo draws.

gms

A logical value indicating whether the generalized moment selection procedure should be used.

Value

  • For cohorts = NULL or a single cohort: a numeric scalar p-value.

  • For a cohort_set: the input tibble with an added numeric column design_effect_pval containing the p-value for each cohort.

Examples

# Note: `example_srv_lx` is simulated from the list-experiment model (i.e.,
# generated under the assumptions tested by `lx_design_effect()`), so these
# examples return p-values of 1 (no evidence of design effects).
# Parse the shipped example survey and pick one experiment ("pets")
parsed <- lx_parse_data(
  example_srv_lx,
  n_insens = 4,
  id_col = response_id,
  treatment = m2_list_treatment,
  private = "m2_list_{exp}_private",
  public = "m3_list_{exp}_public",
  majority = "m3_list_{exp}_majority",
  predictors = tidyselect::starts_with("d_"),
  treatment_coding = c(control = "ctrl", treatment = "trt")
)
#> ℹ No `weight_col` provided. Using equal weights of 1. Weights do not affect model fitting. But if you want quick summaries for cohorts generated from model predictors to use your survey weighting, set `weight_col` at parse time.
#> 
#> ── Experiment pets 
#> • treatment column: m2_list_treatment
#> ├─ treatment <- "trt"
#> └─ control   <- "ctrl"
#> • private column: m2_list_pets_private
#> • public column: m3_list_pets_public
#> ├─ disagree <- "oppose"
#> ├─ unsure   <- "mixed"
#> └─ agree    <- "support"
#> • majority column: m3_list_pets_majority
#> ├─ disagree <- "oppose"
#> ├─ unsure   <- "mixed"
#> └─ agree    <- "support"
#> 
#> ── Experiment privacy 
#> • treatment column: m2_list_treatment
#> ├─ treatment <- "trt"
#> └─ control   <- "ctrl"
#> • private column: m2_list_privacy_private
#> • public column: m3_list_privacy_public
#> ├─ unsure   <- "mixed"
#> ├─ disagree <- "oppose"
#> └─ agree    <- "support"
#> • majority column: m3_list_privacy_majority
#> ├─ unsure   <- "mixed"
#> ├─ disagree <- "oppose"
#> └─ agree    <- "support"
#> 
#> ── Experiment climate 
#> • treatment column: m2_list_treatment
#> ├─ treatment <- "trt"
#> └─ control   <- "ctrl"
#> • private column: m2_list_climate_private
#> • public column: m3_list_climate_public
#> ├─ disagree <- "oppose"
#> ├─ unsure   <- "mixed"
#> └─ agree    <- "support"
#> • majority column: m3_list_climate_majority
#> ├─ agree    <- "support"
#> ├─ disagree <- "oppose"
#> └─ unsure   <- "mixed"
pets_data <- parsed$data$pets

# Whole sample
set.seed(123)
lx_design_effect(pets_data, n.draws = 2000)
#> [1] 0.1909608

# Single cohort
cohort_female <- example_srv_lx |>
  dplyr::filter(d_gender == "female") |>
  g6tr.cohorts::create_cohort(id_col = response_id, weight_col = weight)

set.seed(123)
lx_design_effect(pets_data, cohorts = cohort_female, n.draws = 2000)
#> [1] 0.1804317

# Cohort set
cohort_set <- example_srv_lx |>
  g6tr.cohorts::create_cohort_set(
    id_col = response_id,
    grp_cols = c(d_gender),
    weight_col = weight
  )

set.seed(123)
res <- lx_design_effect(pets_data, cohorts = cohort_set, n.draws = 2000)
res$design_effect_pval
#> [1] 0.1909608 0.8075451 0.1804317