Skip to contents

Computes an unbiased estimate of the variance of the weighted sample mean.

Usage

uevarwm(x, weights, na.rm = T)

Arguments

x

vector of measurements

weights

vector of weights

na.rm

logical, whether NA values in x should be stripped before the computation proceeds

Value

A length-one numeric vector.

Details

Currently, this implementation is not considering eventual stratification in the estimate of the variance. We also assume that the measurements (i.e. x) are drawn from the same population with variance \(V(x_{i}) = \sigma_{x}^2\).

The variance of the sample mean is then computed as

$$\hat{\sigma}_{W}^{2} = V(\frac{\sum_{i=1}^{n} w_{i}x_{i}}{\sum_{i=1}^{n} w_{i}}) = \frac{1}{(\sum_{i=1}^{n} w_{i})^2} V(\sum_{i=1}^{n} w_{i}x_{i}) = \frac{\sum_{i=1}^{n} w_{i}^2}{(\sum_{i=1}^{n} w_{i})^2} \sigma_{x}^2$$

There are different ways to estimate the variance of the x (\(\sigma_{x}^2\)). Here we use the common formula for unbiased estimator of unweighted data

$$s_{x}^2 = \frac{\sum_{i=1}^{n} (x_{i} - \bar{x})^2}{n - 1}$$

Author

Alessandro Barberis