Skip to contents

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

Usage

prec_mean(var = NULL, ...)

# Default S3 method
prec_mean(
  var = NULL,
  n,
  ...,
  sd = NULL,
  mu = NULL,
  cv = NULL,
  alpha = 0.05,
  N = Inf,
  deff = 1,
  resp_rate = 1,
  df = NULL,
  plan = NULL
)

# S3 method for class 'svyplan_n'
prec_mean(var, ...)

Arguments

var

For the default method: population variance \(S^2\). For svyplan_n objects: a sample size result from n_mean().

...

Additional arguments passed to methods. Unused arguments are rejected.

n

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

sd

Population standard deviation, an alternative spelling of var. Supply exactly one of var or sd. Stratum frames and published survey reports usually quote standard deviations.

mu

Population mean. Required for the CV component.

cv

Target relative standard error, supplied instead of mu to solve for the smallest mean the design measures that precisely. Supply at most one of mu or cv. Omitting both leaves cv undefined, as before.

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.

df

Degrees of freedom of the variance estimator the planned design will have, typically sampled PSUs minus strata, and available from design_df(). It switches the interval quantile from normal to t. NULL (default) applies no adjustment. See n_prop() for the full account.

plan

Optional svyplan() object providing design defaults.

Value

A svyplan_prec object with type = "mean":

se

Standard error of the planned estimate, computed on the net sample n * resp_rate.

moe

Margin of error, qnorm(1 - alpha / 2) * se. The interval is symmetric, so the limits are mu - moe and mu + moe.

cv

Relative standard error, se / abs(mu). NA when mu is not supplied, since a relative standard error needs a mean to be relative to.

solved

"mu" when the mean was solved for, and absent otherwise. The solved value is in params$mu.

params

The validated inputs (var, n, alpha, N, deff, resp_rate, and mu when given or solved for). Dispersion is always stored as var, including when you supplied sd. predict(), confint() and the n_mean() round trip read the design back from here.

Nothing here is rounded: n is taken as given, so passing a continuous n back from n_mean() reproduces its se, moe and cv exactly.

Details

Computes the standard error for the given sample size and design parameters, then derives the margin of error and coefficient of variation. The effective sample size is n * resp_rate / deff, with optional finite population correction.

Supplying cv in place of mu solves the same equation in the remaining direction, returning the smallest mean the design measures that precisely. The standard error of a mean does not involve the mean, so this is a division rather than a search, and only the magnitude is recoverable: cv is defined against abs(mu), and the positive root is returned. See prec_prop() for the proportion case, where the same reading answers which estimates a fielded design can carry.

Round-trip with n_mean

prec_mean() is the inverse of n_mean(): if you compute res <- n_mean(var = 100, moe = 2) and then call prec_mean(res), you will recover moe = 2. You can also pass an svyplan_n object directly: prec_mean(res).

Precision of a total

A separate prec_total() is not needed. The precision of the estimated total \(\hat{Y} = N \bar{y}\) is a rescaling of the mean precision:

  • \(SE(\hat{Y}) = N \times SE(\bar{y})\)

  • \(MOE(\hat{Y}) = N \times MOE(\bar{y})\)

  • \(CV(\hat{Y}) = CV(\bar{y})\)

Call prec_mean() and multiply $se and $moe by \(N\) for the total. The $cv component is identical. See Examples below.

See also

n_mean() for the inverse (compute n from a precision target), prec_prop() for proportions.

Other precision functions: prec_alloc(), prec_change(), prec_cluster(), prec_multi(), prec_multi_cluster(), prec_panel(), prec_pooled(), prec_prop(), prec_twophase()

Examples

# Precision with n = 400
prec_mean(var = 100, n = 400, mu = 50)
#> Sampling precision for mean
#> n = 400
#> se = 0.5000, moe = 0.9800, cv = 0.0100, rmoe = 0.0196

# Without mu (CV will be NA)
prec_mean(var = 100, n = 400)
#> Sampling precision for mean
#> n = 400
#> se = 0.5000, moe = 0.9800

# Smallest mean 400 units can report at a 5 percent CV
prec_mean(var = 100, n = 400, cv = 0.05)$params$mu
#> [1] 10

# Round-trip from n_mean
res <- n_mean(var = 100, moe = 2)
prec_mean(res)
#> Sampling precision for mean
#> n = 97
#> se = 1.0204, moe = 2.0000

## Precision of a total
# Precision of a mean, then scale to total
N <- 10000
p <- prec_mean(var = 2500, n = 400, mu = 300, N = N)
p$moe * N   # MOE for the estimated total
#> [1] 48009.12
p$se * N    # SE for the estimated total
#> [1] 24494.9
p$cv        # CV is the same for mean and total
#> [1] 0.008164966