Description Usage Arguments Details Value Author(s) References See Also Examples
The function stratamean
estimates the population mean out of stratified samples either with or without consideration of finite population correction.
1 | stratamean(y, h, Nh, wh, level = 0.95, eae = FALSE)
|
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 |
|
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.
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 |
Shuai Shao and Juliane Manitz
Kauermann, Goeran/Kuechenhoff, Helmut (2010): Stichproben. Methoden und praktische Umsetzung mit R. Springer.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.