equivalentSample | R Documentation |
Take estimates of probabilities or rates from a complex survey,
along with the associated standard errors, and turn them into counts and
effective sample sizes that can be analysed using area-level models,
such as those implemented by estimateModel
.
equivalentSample(mean, se, to = c("binomial", "Poisson"), epsilon = 1e-06)
## S4 method for signature 'Values,Values'
equivalentSample(mean, se, to = c("binomial", "Poisson"), epsilon = 1e-06)
mean |
An object of class |
se |
An object of class |
to |
The distribution that the effective counts are generated
from: |
epsilon |
A small number. Values for |
Most surveys of households or individuals firms are 'complex', in that they use techniques such as stratification and clustering which do not yield simple random samples from the population of interest. When analysing data from complex surveys, the survey design must be taken into account.
The cleanest way to take the survey design into account is to include in the model all the features of the survey design that are likely to be correlated with the outcome variables. For instance, if the survey uses stratification, then the model should include strata-level effects. (Gelman et al 2014, Chapter 8.)
Incorporating all the relevant features of a complex survey is much
easier with individual-level models than with the cell-level or
area-level models implemented by estimateModel
. Some
applications are, however, more suited to area-level models than
to individual-level models. An example is the forecasting of area-level
quantities such as disease prevalence. Statisticians therefore looked for
ways of fitting area-level models to data from complex surveys.
Function equivalentSample
implements the methods developed by Chen,
Wakefield, and Lumley (2014). The input to the function are estimates of
rates or probabilities for each area, together with the standard
errors for these estimates. These estimates arecalculated from complex
survey data using methods that account for the complex survey design
(Lumley 2011). Function equivalentSample
converts the estimates into
counts and sample sizes (which, to be consististent with the terminology
used by estimateModel
, we refer to as exposures.)
The counts and exposures contain the same information as the original
rates or probabilities and standard errors, in that Poisson or binomial
distributions formed from them have the same (or nearly the same) means
and variances as the original design-based estimates. The analysis can then
proceed as if the counts and exposures had been obtained through simple random
sampling from the population of interest.
Both mean
and se
can contain NA
s. The corresponding
counts and exposures will also be NA
. Function
estimateModel
accepts missing values for y
and
exposure
, though a cell in exposure
can only be missing
if the correspondent cell in y
is missing.
Design-based methods for calculating standard errors can break down
when cell sizes are small, giving standard errors of zero.
equivalentSamples
treats as missing elements of se
that
are equal to 0.
A named list with elements y
(the counts) and
exposure
, both of which have class Counts
.
Lumley, T. (2011). Complex Surveys: A Guide to Analysis using R John Wiley & Sons.
Chen C, Wakefield J, and Lumley T (2014). "The use of sampling weights in Bayesian hierarchical models for small area estimation". Spatial and Spatio-temporal Epidemiology. 11: 33-43.
Gelman, A., Carlin, J.B., Stern, H.S. and Rubin, D.B., 2014. Bayesian Ddata Analysis. Third Edition. Chapman & Hall/CRC.
Package survey
contains tools for estimating rates,
probabilities, and standard errors from complex surveys. The output from
equivalentSample
are typically analysed using function
estimateModel
.
mean <- demdata::nz.obesity.mean
se <- demdata::nz.obesity.se
mean <- Values(mean, dimscales = c(time = "Points"))
se <- Values(se, dimscales = c(time = "Points"))
l <- equivalentSample(mean = mean, se = se, to = "Poisson")
names(l)
y <- l$y
exposure <- l$exposure
## 'y' and 'exposure' can now be analysed using
## function 'estimateModel'
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.