Computes an unbiased estimate of the variance of the weighted sample mean.
Arguments
- x
vector of measurements
- weights
vector of weights
- na.rm
logical, whether
NA
values inx
should be stripped before the computation proceeds
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}$$