Learn R Programming

robsurvey (version 0.1.0)

trimwgt: Weighted trimmed mean and trimmed total

Description

Weighted trimmed estimators of the mean and total are available in two forms:

  • bare-bone functions: weighted_mean_trimmed and weighted_total_trimmed,

  • estimation methods: svymean_trimmed and svytotal_trimmed (incl. variance estimation based on the functionality of the survey package).

Usage

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

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

svymean_trimmed(x, design, LB = 0.05, UB = 1 - LB, ...)

svytotal_trimmed(x, design, LB = 0.05, UB = 1 - LB, ...)

Arguments

x

numeric vector (weighted_mean_trimmed or weighted_total_trimmed); a formula object or variable name (svymean_trimmed or svytotal_trimmed)

w

numeric vector of weights

LB

lower bound of trimming, such that \(0 \leq LB < UB \leq 1\)

UB

upper bound of trimming, such that \(0 \leq LB < UB \leq 1\)

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

design

a survey.design object (see svydesign in survey)

...

additional arguments (not used)

Value

Estimate (scalar) or object of class svystat.rob

Utility functions

For the methods svymean_trimmed and svytotal_trimmed, the following utility functions can be used

  • summary gives a summary of the estimation properties

  • robweights retrieves the robustness weights

  • coef, vcov, residuals, and fitted retrieve, respectively, the estimate, variance, residuals and fitted values

Details

Overview

Robust trimmed Horvitz--Thompson total or Hajek mean

  • bare-bone functions: return the estimate (no variance estimation)

  • estimation methods on the basis of survey (incl. variance estimation)

Variance

Variance estimates of the mean or total estimator are computed as first-order linearization using the design-based-estimation capabilities available in package survey.

Domain estimation

Estimates for domains can be obtained using the svyby wrapper in the survey package (see examples).

See Also

svymean_huber, svytotal_huber, svymean_winsorized, svytotal_winsorized, weighted_mean_huber, weighted_total_huber, weighted_mean_winsorized, weighted_total_winsorized

Examples

Run this code
# NOT RUN {
library(survey)
data(api)
dstrat <- svydesign(id=~1, strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
svymean_trimmed(~api00, dstrat, LB = 0.05)
# Domain estimates
svyby(~api00, by = ~stype, design = dstrat, svymean_trimmed, LB = 0.1)
# }

Run the code above in your browser using DataLab