Skip to contents

With design weights \(w_i = 1/\pi_i\) the Horvitz–Thompson total is \(\hat t_y = \sum_i w_i y_i\) and the estimated population size is \(\hat N = \sum_i w_i\). Their ratio \(\bar y_w = \sum_i w_i y_i / \sum_i w_i\) is the Hajek mean. It is a ratio of two estimated totals rather than a linear statistic, so its variance comes from linearisation rather than directly.

Usage

Wmeansr(y, weights)

Arguments

y

Numeric vector of observed values for the sampled units.

weights

Numeric vector of design weights \(w_i = 1/\pi_i\), the same length as y.

Value

Named list with estimate, se, sum_weights, n, method.

Details

The variance estimator is the standard with-replacement linearisation of that ratio, $$v(\bar y_w) = \frac{n}{(n-1)(\sum_i w_i)^2} \sum_i w_i^2 (y_i - \bar y_w)^2,$$ the residual technique of Sarndal, Swensson & Wretman (1992, Section 5.6) applied to the Hajek ratio. This is the same quantity survey::svymean reports for a design declared with ids = ~1; the identity was checked numerically against that package when this function was written.

weights are design weights \(1/\pi_i\), not frequencies. Zero weights drop a unit; negative weights are rejected.

Mirrors morie.fn.wmeansr on the Python side.

References

Horvitz D G & Thompson D J (1952). A generalization of sampling without replacement from a finite universe. JASA 47(260), 663–685.

Thompson S K (2012). Sampling, 3rd ed. Wiley, Chapter 6.

Sarndal C-E, Swensson B & Wretman J (1992). Model Assisted Survey Sampling. Springer, Section 5.6.

Examples

Wmeansr(c(3.1, 5.2, 2.8, 9.4), c(1.5, 2, 0.5, 3))$se
#> [1] 1.769771