Skip to contents

For the overall survey: given weights and/or a sample size, the maximum margin of error gives us the upper bound on the margin of error for all y/n questions across the entire survey – by estimating it for a hypothetical y/n question with 50/50 (the inherently most uncertain population estimand).

Usage

esti_moe(.data = NULL, weights = NULL, n = NULL, x = NULL, conf = 0.95)

Arguments

.data

data frame to optionally pipe in dplyr-style (see example).

weights

vector of sample weights used to adjust the sample (optional if n or x is specified).

n

the sample size of the suvrey (not needed if weights or x is specified).

x

the particular question to estimate margin of error for (if not specified, estimate the survey's MOE instead).

conf

the level of statistical confidence to estimate the error.

Value

The survey margin of error (MOE) or "modeled error" for the overall survey or question of interest.

Details

For a single question: given a vector of sample responses and/or weights, the margin of error estimates the margin of error by plugging into known quantiles of the asymptotic sampling distribution.

Estimates from this asymptotic formula tend to be smaller than using the simulated margin of error (sim_modeled_error) as it assumes all our survey's questions follow an asymptotic normal distribution (i.e. a large sample of independent observations).

For non-probability surveys without design weights, it is recommended to use `sim_modeled_error`.

Examples


data(ev22)
if (FALSE) { ## not run

# Unweighted maximum margin of error
esti_moe(n = nrow(ev22))
esti_moe(weights = rep(1, nrow(ev22)))

# Weighted maximum margin of error
esti_moe(weights = ev22$weight_genpop)

# Unweighted margin of error for specific question
esti_moe(x = ev22$ev_heard_1)

# Weighted margin of error for specific question
ev22 %>%
  filter(!is.na(weight_genpop)) %>%
  esti_moe(x = ev_heard_1, weights = weight_genpop)
}