Skip to contents

The weights are reliability weights: an observation of weight w counts as w observations, so the denominator is sum(w) - 1 rather than n - 1. With every weight equal to one this is exactly the unbiased sample variance.

Usage

Wvar(y, weights = NULL)

Arguments

y

Numeric observations.

weights

Optional non-negative weights; equal weights if NULL.

Value

List with estimate (weighted variance), mean, sd, se, sumw, n, method.

Details

Formula: ybar_w = sum(w y) / sum(w), s2_w = sum(w (y - ybar_w)^2) / (sum(w) - 1).

References

Lohr, S. L. (2010). Sampling: Design and Analysis, 2nd ed. Brooks/Cole, section 7.2.

Examples

Wvar(c(1, 2, 3, 10))
#> $estimate
#> [1] 16.66667
#> 
#> $mean
#> [1] 4
#> 
#> $sd
#> [1] 4.082483
#> 
#> $se
#> [1] 2.041241
#> 
#> $sumw
#> [1] 4
#> 
#> $n
#> [1] 4
#> 
#> $method
#> [1] "weighted variance, sum(w (y-ybar_w)^2)/(sum(w)-1) [Lohr 2010]"
#>