weighted_mean function

Weighted Total and Mean (Horvitz-Thompson and Hajek Estimators)

Weighted Total and Mean (Horvitz-Thompson and Hajek Estimators)

Weighted total and mean (Horvitz-Thompson and Hajek estimators)

weighted_mean(x, w, na.rm = FALSE) weighted_total(x, w, na.rm = FALSE)

Arguments

  • x: [numeric vector] data.
  • w: [numeric vector] weights (same length as x).
  • na.rm: [logical] indicating whether NA values should be removed before the computation proceeds (default: FALSE).

Details

weighted_total and weighted_mean compute, respectively, the Horvitz-Thompson estimator of the population total and the Hajek estimator of the population mean.

Returns

Estimated population mean or total

See Also

Overview (of all implemented functions)

Examples

head(workplace) # Horvitz-Thompson estimator of the total weighted_total(workplace$employment, workplace$weight) # Hajek estimator of the mean weighted_mean(workplace$employment, workplace$weight)
  • Maintainer: Tobias Schoch
  • License: GPL (>= 2)
  • Last published: 2024-08-22