tsvymean: Trimmed and winsorized weighted mean for complex samples

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/tsvymean.R

Description

tsvymean computes either the trimmed or winsorized weighted mean for complex samples.

Usage

1
2
tsvymean(y, design, trim = c(0, 0), type = c("trim", "win"), 
         na.rm=FALSE, control = rht.control(...), ...)

Arguments

y

a formula object (only one variable)

design

a survey.design object

trim

vector of size two consisting of the lower and upper amount of trimming ([lo, hi]). The fraction lo of observations is trimmed from the lower end and the fraction hi is trimmed from the upper end. The symmetrically 5%-trimmed mean is obtained with trim=c(0.05, 0.05). Alternatively, one may specify the amount of trimming in terms of integer values; e.g., trim=c(0, 6) trims only the largest 6 observations.

type

either "trim" for trimming (default), or "win" for winsorization

na.rm

should cases with missing values be dropped? (default FALSE)

control

control object; see rht.control

...

additional specifications

Details

By default trim equals c(0,0) and the regular weighted mean is computed. The variance estimators are based on first-order linearizations using the design-based-estimation facilities of the survey package. For reasons of numerical stability, the variance of the winsorized weighted mean is computed using the variance estimator of the trimmed mean.

tsvymean allows also the estimation for domains. Use the command subset and a design subset expression instead of the original survey.design object in tsvymean (see examples for more details).

Value

Object of class "svystat.rob"

The following (S3) methods are defined for objects of the class "svystat.rob":

Author(s)

Tobias Schoch

References

Hulliger, B. (1999): Simple and robust estimators for sampling, Proceedings of the Survey Research Methods Section, American Statistical Association, 1999, pp. 54-63.

Hulliger, B. and T. Schoch (2011): Elementary robust estimators. In: Robust methodology for Laeken indicators: AMELI Deliverable D4.2, ed. by B. Hulliger, A. Alfons, P. Filzmoser, A. Meraner, T. Schoch and M. Templ. AMELI Project.

See Also

svymean

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## load "api" data set from "survey" package (a description of the data
## set can be found there)
data(api)
## define "survey.design" for stratified sampling
dstrat <- svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, 
fpc=~fpc)
## compute a robust Horvitz-Thompson estimate for the mean of the 
## variable "api00" (Academic Performance Index in 2000)
tm1 <- tsvymean(~api00, dstrat, trim=c(0.01, 0.09), type="trim")
# get a summary of the estimation
summary(tm1)
## robust estimates for a domain of the variable. Here we are 
## interessted in the trimmed mean for api00 in case of 
## (sch.wide == "Yes"). That is the average of the academic performance
## in 2000 only for the schools that met the school-wide growth target.
tsvymean(~api00, subset(dstrat, sch.wide == "Yes"), trim=c(0.01, 0.09), 
type="trim")
## to extract the estimate from the object use
coef(tm1) 
## to extract the variance from the object use
vcov(tm1)

rhte documentation built on May 2, 2019, 6:24 p.m.