Description Usage Arguments Value References Examples
View source: R/srs_functions.R
Function to get point estimates and statistics associated with them.
Given a point estimate (mean, total, prop), mk_stat
will generate the
sample size, n, at calling time
point estimate
estimator variance
standard error
coefficient of variation assuming a simple random sample of data.
1 |
y |
A numeric vector with at least two elements |
stat |
A string, either "mean", "total", or "prop" (proportion) |
N |
The population size. This must be supplied and must be larger than length(y). If unknown, recommend passing it as some N > n with fpc=FALSE. |
fpc |
TRUE/FALSE. Whether or not to compute a finite population correction (for variance). |
weights |
Optional. If passed, it must be a vector of weights at least as long as the input y. |
tibble with
n (sample size)
point estimate (stat: mean, total, proportion)
estimator variance (not the same as population variance)
estimator standard error
coefficient of variation
Lohr, Sharon L. Sampling: Design and Analysis. Chapman and Hall/CRC, 2019.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | N <- 10
n <- 5
y <- c(0, 0, 0, 1, 1)
weights <- rep(N/n, n)
mk_stat(y, stat="mean", N, fpc=TRUE, weights=weights)
# A tibble: 1 x 5
# n point var se cv
# <int> <dbl> <dbl> <dbl> <dbl>
#1 5 0.4 0.15 0.387 0.968
N <- 10
n <- 5
y <- c(0, 0, 0, 1, 1)
weights <- rep(N/n, n)
mk_stat(y, stat="total", N, fpc=TRUE, weights=weights)
# A tibble: 1 x 5
# n point var se cv
# <int> <dbl> <dbl> <dbl> <dbl>
#1 5 4 15 3.87 0.968
#' N <- 10
n <- 5
y <- c(0, 0, 0, 1, 1)
weights <- rep(N/n, n)
mk_stat(y, stat="prop", N, fpc=TRUE, weights=weights)
# A tibble: 1 x 5
# n point var se cv
# <int> <dbl> <dbl> <dbl> <dbl>
#1 5 0.4 0.03 0.173 0.433
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.