weighted_mean_trimmed: Weighted Trimmed Mean and Total (bare-bone functions)

View source: R/weighted_mean_trimmed.R

weighted_mean_trimmedR Documentation

Weighted Trimmed Mean and Total (bare-bone functions)

Description

Weighted trimmed mean and total (bare-bone functions with limited functionality; see svymean_trimmed and svytotal_trimmed for more capable methods)

Usage

weighted_mean_trimmed(x, w, LB = 0.05, UB = 1 - LB, info = FALSE,
    na.rm = FALSE)
weighted_total_trimmed(x, w, LB = 0.05, UB = 1 - LB, info = FALSE,
    na.rm = FALSE)

Arguments

x

[numeric vector] data.

w

[numeric vector] weights (same length as x).

LB

[double] lower bound of trimming such that 0 ≤q LB < UB ≤q 1.

UB

[double] upper bound of trimming such that 0 ≤q LB < UB ≤q 1.

info

[logical] indicating whether additional information should be returned (default: FALSE).

na.rm

[logical] indicating whether NA values should be removed before the computation proceeds (default: FALSE).

Details

Characteristic.

Population mean or total. Let μ denote the estimated trimmed population mean; then, the estimated trimmed population total is given by Nhat μ with Nhat = sum(w[i]), where summation is over all observations in the sample.

Trimming.

The methods trims the LB~\cdot 100\% of the smallest observations and the (1 - UB)~\cdot 100\% of the largest observations from the data.

Variance estimation.

See survey methods:

  • svymean_trimmed,

  • svytotal_trimmed.

Value

The return value depends on info:

info = FALSE:

estimate of mean or total [double]

info = TRUE:

a [list] with items:

  • characteristic [character],

  • estimator [character],

  • estimate [double],

  • variance (default: NA),

  • robust [list],

  • residuals [numeric vector],

  • model [list],

  • design (default: NA),

  • [call]

See Also

Overview (of all implemented functions)

svymean_trimmed and svytotal_trimmed

Examples

data(workplace)

# Estimated trimmed population total (5% symmetric trimming)
weighted_total_trimmed(workplace$employment, workplace$weight, LB = 0.05,
    UB = 0.95)

# Estimated trimmed population mean (5% trimming at the top of the distr.)
weighted_mean_trimmed(workplace$employment, workplace$weight, UB = 0.95)

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