Skip to contents

Compute the sampling error (SE, margin of error, CV) for estimating a population proportion given a sample size. This is the inverse of n_prop().

Usage

prec_prop(p, ...)

# Default S3 method
prec_prop(
  p,
  n,
  ...,
  alpha = 0.05,
  N = Inf,
  deff = 1,
  resp_rate = 1,
  method = c("wald", "wilson", "logodds"),
  plan = NULL
)

# S3 method for class 'svyplan_n'
prec_prop(p, ...)

Arguments

p

For the default method: expected proportion, in (0, 1). For svyplan_n objects: a sample size result from n_prop().

...

Additional arguments passed to methods. Unused arguments are rejected.

n

Sample size, measured as gross units drawn and bounded by a finite N.

alpha

Significance level, default 0.05.

N

Population size. Inf (default) means no finite population correction.

deff

Design effect multiplier (> 0). Values < 1 are valid for efficient designs (e.g., stratified sampling with Neyman allocation).

resp_rate

Expected response rate, in (0, 1]. Default 1 (no adjustment). The effective sample size is n * resp_rate.

method

One of "wald" (default), "wilson", or "logodds".

plan

Optional svyplan() object providing design defaults.

Value

A svyplan_prec object with components $se, $moe, and $cv.

Details

Computes the standard error for the given sample size and design parameters, then derives the margin of error and coefficient of variation. The variance equation is se^2 = deff * p * (1 - p) * fpc(n_net) / n_net, where n_net = n * resp_rate is the expected number of responding units: deff multiplies the SRS variance at the realized sample size, and the finite population correction uses the actual sampling fraction n_net / N. Equivalently, se^2 = p * (1 - p) * fpc(n_net) / n_eff with the effective sample size n_eff = n_net / deff.

The Wald FPC uses the Cochran (1977, Ch. 3) form: the finite-population correction for a Bernoulli proportion is (N - n_net) / (N - 1), not the simpler 1 - n_net / N used for means. The Wilson method has no finite-population form. It is evaluated at n_eff and ignores N.

When called on a svyplan_n object, parameters are extracted from the stored result. Any argument of the default method (e.g. method, deff, N) can be overridden through .... Unknown argument names are an error. Passing a different method evaluates the stored sample size under that formula. The round-trip will not be exact because n was determined under the original method.

See also

n_prop() for the inverse (compute n from a precision target), prec_mean() for continuous variables.

Examples

# Precision with n = 400
prec_prop(p = 0.3, n = 400)
#> Sampling precision for proportion (wald)
#> n = 400
#> se = 0.0229, moe = 0.0449, cv = 0.0764

# With design effect and response rate
prec_prop(p = 0.3, n = 400, deff = 1.5, resp_rate = 0.8)
#> Sampling precision for proportion (wald)
#> n = 400 (net: 320)
#> se = 0.0314, moe = 0.0615, cv = 0.1046