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,
  eligibility_rate = 1,
  eligible_per_unit = 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). A published DEFT is squared first. See varcomp() for that and for removing the published survey's weighting loss.

resp_rate

Expected response rate among eligible units, in (0, 1]. Default 1 (no adjustment). The effective sample size is n * resp_rate. A rate of eligible units per sampled unit at or below 1, such as 0.41 married women per household, folds in here as resp_rate * eligible_per_unit. With a finite N this errs slightly conservative. See the nonresponse section of svyplan-package for what the rate counts.

eligibility_rate

Share of issued units in scope, such as dwellings found occupied, in (0, 1]. Default 1. With a finite N, the population in scope is N * eligibility_rate. See the nonresponse section of svyplan-package.

eligible_per_unit

Eligible units per sampled unit, a positive number, default 1, such as women aged 15 to 49 per household, and it can exceed 1. n and N stay in sampled units, while the precision is computed on the eligible respondents out of N * eligibility_rate * eligible_per_unit eligible units. Above 1, deff must carry the correlation among the eligible units of one sampled unit. See the section on eligible units in n_prop().

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, q * se, with q defined in Details. 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, df, 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. The print shows n as evaluated, and for a fit it says that n is the continuous optimum. For a fit res, the whole sample to field is ceiling(res$n), and prec_mean(res, n = ceiling(res$n)) gives its precision.

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. The quantile q is qnorm(1 - alpha / 2) by default and qt(1 - alpha / 2, df) when df is supplied.

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, prec_multi() for several indicators or for one indicator in several domains, prec_alloc() for a stratified allocation as a whole and by domain.

Other sample size and precision functions: n_mean(), n_prop(), n_ratio(), prec_prop(), prec_ratio()

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, then the whole sample to field
res <- n_mean(var = 100, moe = 2)
prec_mean(res)
#> Sampling precision for mean (continuous optimum)
#> n = 96.03647
#> se = 1.0204, moe = 2.0000
prec_mean(res, n = ceiling(res$n))
#> Sampling precision for mean
#> n = 97
#> se = 1.0153, moe = 1.9900

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


# The same households measured on about 2.6 women each
prec_mean(var = 16, n = 400, deff = 1.8, resp_rate = 0.9,
          eligible_per_unit = 2.6)
#> Sampling precision for mean
#> n = 400 (eligible respondents: 936, eligible_per_unit = 2.6)
#> se = 0.1754, moe = 0.3438