stratamean {samplingbook} | R Documentation |
Stratified Sample Mean Estimation
Description
The function stratamean
estimates the population mean out of stratified samples either with or without consideration of finite population correction.
Usage
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 |
eae |
|
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: |
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
Examples
# 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)