Description Usage Arguments Value References Examples
View source: R/stratified_sample.R
Helper to compute stratified estimates for means, totals, and proportions.
Composes tables from make_summary
to estimate the stratified statistic.
1 | stratified_stat(.tbl, .stat = "mean", .fpc = TRUE)
|
.tbl |
Output from (or similar to) |
.stat |
One of "mean", "total", or "prop" |
.fpc |
Logical to use or exclude a finite population correction |
A tibble table combining components of a stratified estimator and providing estimates for
Ntotal |
The total population size |
ntotal |
The total sample size |
point |
The point estimate (stat) provided |
var |
The variance of the point estimator |
se |
The standard error |
cv |
The coefficient of variation |
Lohr, Sharon L. Sampling: Design and Analysis. Chapman and Hall/CRC, 2019.
1 2 3 4 5 6 7 8 9 | # First need to get output from make_summary
d <- data.frame("stratum"=rep(1:5, 6), "y"=rnorm(30, 30, 3))
N <- 50
ms <- make_summary(d, stratum, y, N, .stat="total")
stratified_stat(ms, .stat="total")
# Can equivalently pipe the output from make_summary into stratified_stat
# (Note how easily the estimated statistic can be computed)
make_summary(d, stratum, y, N, .stat="mean") %>%
stratified_stat(.stat="mean")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.