Skip to contents

Compute the required sample size for estimating a population mean with a specified margin of error or coefficient of variation.

Usage

n_mean(var = NULL, ...)

# Default S3 method
n_mean(
  var = NULL,
  ...,
  sd = NULL,
  mu = NULL,
  moe = NULL,
  cv = NULL,
  rmoe = 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_prec'
n_mean(var, ..., moe = NULL, cv = NULL, rmoe = NULL)

Arguments

var

For the default method: population variance \(S^2\). Estimate from a pilot study, a previous survey, or published data for a similar population. When uncertain, use a conservative (larger) estimate to avoid under-sizing. For svyplan_prec objects: a precision result from prec_mean().

...

Additional arguments passed to methods. Unused arguments are rejected.

sd

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

mu

Population mean. Required when cv or rmoe is specified, both being defined against the mean.

moe

Desired margin of error, the half-width of the confidence interval, in the same units as the variable. For example, if measuring income in dollars, moe = 50 means the 95 percent CI should be no wider than +/- $50. Specify exactly one of moe, cv, or rmoe.

cv

Target coefficient of variation (relative standard error). For example, cv = 0.05 means the standard error should be at most 5 percent of the estimate. Use cv when you want precision to scale with the estimate (common in economic surveys). Use moe when you want a fixed absolute precision. Requires mu. Specify exactly one of moe, cv, or rmoe.

rmoe

Target margin of error relative to mu, so rmoe = 0.05 asks for a 95 percent interval whose half-width is 5 percent of the mean. It is moe / abs(mu), taken on the magnitude so that a negative mean gives a positive margin of error, and it requires mu. Specify exactly one of moe, cv, or rmoe.

alpha

Significance level, default 0.05.

N

Population size. Inf (default) means no finite population correction. Setting a finite N reduces the required sample size when the sampling fraction is non-negligible (rule of thumb: matters when n/N > 5 percent).

deff

Design effect multiplier (> 0). See n_prop() for guidance on estimating DEFF. 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 required sample size is inflated by 1 / resp_rate. See the nonresponse section of svyplan-package for what the rate counts and what this adjustment does and does not claim. 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.

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_n object with type = "mean":

n

Required sample size, continuous and gross. It already carries deff and the 1 / resp_rate inflation, so it counts the units to release, not the completed interviews. $n and as.double() keep the unrounded value, which is what makes the round trip through prec_mean() exact. print() and as.integer() round it up to the whole units you would field. Take the field figure from as.integer() rather than from $n.

se, moe, cv, rmoe

Precision the design achieves at that n, the same values prec_mean() reports for the same inputs. moe is q * se, with q defined in Details, and the interval is symmetric about the mean. cv and rmoe are NA unless mu was supplied, both needing a mean to be relative to.

params

The validated inputs (var, alpha, N, deff, resp_rate, df, mu when given, and whichever of moe, cv, or rmoe was the target). Dispersion is always stored as var, including when you supplied sd. predict(), confint() and the prec_mean() round trip read the design back from here.

Details

Two modes:

  • MOE mode: n = deff * q^2 * var / (moe^2 + deff * q^2 * var / N). An rmoe target enters here as moe = rmoe * abs(mu).

  • CV mode: Computes CVpop = sqrt(var) / abs(mu), then n = deff * CVpop^2 / (cv^2 + deff * CVpop^2 / N).

deff appears in the denominator as well as the numerator, so it inflates the variance the finite population correction is then applied to, rather than scaling a size already corrected. The two coincide only at infinite N. For var = 100, moe = 2, N = 100 and deff = 2, inflating afterward would give 97.98 against the correct 65.76.

Finite population correction

Setting N to a finite value reduces the required sample size when the sampling fraction (n/N) is non-negligible (rule of thumb: matters when n/N > 5 percent). Unlike n_prop(), no N/(N-1) adjustment is needed because var is already defined on N-1 degrees of freedom. See n_prop() for a fuller explanation of FPC.

Here q is qnorm(1 - alpha / 2) by default and qt(1 - alpha / 2, df) when df is supplied. Thus df changes the interval margin of error but not the sampling standard error or CV.

Sample size for a total

A separate n_total() function is not needed because the sample size for a population total \(\hat{Y} = N \bar{y}\) is identical to the sample size for the mean. The two are related by a factor of \(N\):

  • CV mode: \(CV(\hat{Y}) = CV(\bar{y})\), so the required sample size is the same. Use n_mean(var, mu, cv) directly.

  • MOE mode: \(MOE(\hat{Y}) = N \times MOE(\bar{y})\), so divide the target MOE for the total by \(N\): n_mean(var, moe = moe_total / N, N = N).

See Examples below.

References

Cochran, W. G. (1977). Sampling Techniques (3rd ed.). Wiley.

Valliant, R., Dever, J. A., and Kreuter, F. (2018). Practical Tools for Designing and Weighting Survey Samples (2nd ed.). Springer.

See also

n_prop() for proportions, n_cluster() for multistage designs, n_multi() for several indicators or for one indicator in several domains, prec_mean() for the inverse.

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

Examples

# MOE mode
n_mean(var = 100, moe = 2)
#> Sample size for mean
#> n = 97 (var = 100.00, moe = 2.000, deff = 1)

# CV mode
n_mean(var = 100, mu = 50, cv = 0.05)
#> Sample size for mean
#> n = 16 (var = 100.00, cv = 0.050, deff = 1)

# Relative MOE mode: interval half-width 5 percent of the mean
n_mean(var = 100, mu = 50, rmoe = 0.05)
#> Sample size for mean
#> n = 62 (var = 100.00, rmoe = 0.050, deff = 1)

# With FPC, design effect, and response rate
n_mean(var = 100, moe = 2, N = 5000, deff = 1.5, resp_rate = 0.8)
#> Sample size for mean
#> n = 176 gross (net: 141) (var = 100.00, moe = 2.000, deff = 1.50, resp_rate = 0.80)

## Sample size for a total
# Target: estimate total income (N = 10000) with MOE of 500000
n_mean(var = 2500, moe = 500000 / 10000, N = 10000)
#> Sample size for mean
#> n = 4 (var = 2500.00, moe = 50.000, deff = 1)

# CV mode: identical for means and totals
n_mean(var = 2500, mu = 300, cv = 0.05, N = 10000)
#> Sample size for mean
#> n = 12 (var = 2500.00, cv = 0.050, deff = 1)


# Mean age at first birth among women 15 to 49, about 2.6 per household,
# sized in households. The design effect is the person-level one.
n_mean(var = 16, moe = 0.3, deff = 1.8, resp_rate = 0.9,
       eligible_per_unit = 2.6)
#> Sample size for mean
#> n = 526 gross (eligible respondents: 1230) (var = 16.00, moe = 0.300, deff = 1.80, resp_rate = 0.90, eligible_per_unit = 2.6)