stratified_stat: Estimate the stratified statistic from a stratified sample...

Description Usage Arguments Value References Examples

View source: R/stratified_sample.R

Description

Helper to compute stratified estimates for means, totals, and proportions. Composes tables from make_summary to estimate the stratified statistic.

Usage

1
stratified_stat(.tbl, .stat = "mean", .fpc = TRUE)

Arguments

.tbl

Output from (or similar to) make_summary

.stat

One of "mean", "total", or "prop"

.fpc

Logical to use or exclude a finite population correction

Value

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

References

Lohr, Sharon L. Sampling: Design and Analysis. Chapman and Hall/CRC, 2019.

Examples

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")

danjdrennan/surveyr documentation built on Dec. 19, 2021, 8:08 p.m.