weighted_mean: Weighted Total and Mean (Horvitz-Thompson and Hajek...

View source: R/weighted_mean.R

weighted_meanR Documentation

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

Description

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

Usage

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.

Value

Estimated population mean or total

See Also

Overview (of all implemented functions)

Examples

data(workplace)

# Horvitz-Thompson estimator of the total
weighted_total(workplace$employment, workplace$weight)

# Hajek estimator of the mean
weighted_mean(workplace$employment, workplace$weight)

robsurvey documentation built on Jan. 6, 2023, 5:09 p.m.