stratamean: Stratified Sample Mean Estimation

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

View source: R/stratamean.R

Description

The function stratamean estimates the population mean out of stratified samples either with or without consideration of finite population correction.

Usage

1
stratamean(y, h, Nh, wh, level = 0.95, eae = FALSE)

Arguments

y

vector of target variable.

h

vector of stratifying variable.

Nh

vector of sizes of every stratum, which has to be supplied in alphabetical or numerical order of the categories of h.

wh

vector of weights of every stratum, which has to be supplied in alphabetical or numerical order of the categories of h.

level

coverage probability for confidence intervals. Default is level=0.95.

eae

TRUE for extensive output with the result in each and every stratum. Default is eae=FALSE.

Details

If the absolute stratum sizes Nh are given, the variances are calculated with finite population correction. Otherwise, if the stratum weights wh are given, the variances are calculated without finite population correction.

Value

The function stratamean returns a value, which is a list consisting of the components

call

is a list of call components: y target variable in sample data, h stratifying variable in sample data, Nh sizes of every stratum, wh weights of every stratum, fpc finite population correction, level coverage probability for confidence intervals

mean

mean estimate for population

se

standard error of the mean estimate for population

ci

vector of confidence interval boundaries for population

Author(s)

Shuai Shao and Juliane Manitz

References

Kauermann, Goeran/Kuechenhoff, Helmut (2010): Stichproben. Methoden und praktische Umsetzung mit R. Springer.

See Also

Smean, Sprop

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# random data
testy <- rnorm(100)
testh <- c(rep("male",40), rep("female",60))
stratamean(testy, testh, wh=c(0.5, 0.5))
stratamean(testy, testh, wh=c(0.5, 0.5), eae=TRUE)

# tax data
data(tax)
summary(tax)

nh <- as.vector(table(tax$Class))
wh <- nh/sum(nh)
stratamean(y=tax$diff, h=as.vector(tax$Class), wh=wh, eae=TRUE)

jmanitz/samplingbook documentation built on April 10, 2021, 4:44 p.m.