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, ...)
# Default S3 method
prec_mean(
var,
n,
mu = NULL,
alpha = 0.05,
N = Inf,
deff = 1,
resp_rate = 1,
plan = NULL,
...
)
# S3 method for class 'svyplan_n'
prec_mean(var, ...)Arguments
- var
For the default method: population variance \(S^2\). For
svyplan_nobjects: a sample size result fromn_mean().- ...
Additional arguments passed to methods.
- n
Sample size.
- mu
Population mean magnitude (positive). Required for the CV component.
- 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.- plan
Optional
svyplan()object providing design defaults.
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.
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.
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
# Without mu (CV will be NA)
prec_mean(var = 100, n = 400)
#> Sampling precision for mean
#> n = 400
#> se = 0.5000, moe = 0.9800
# 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