finiteY: Estimate or predict finite-population quantity 'y'.

View source: R/query-functions.R

finiteYR Documentation

Estimate or predict finite-population quantity 'y'.

Description

Estimate or predict finite-population quantities for the toal population, from estimated rates, probabilities, or means for the sampled population, plus information on the sizes of the sampled and total population.

Usage

finiteY(filename, total, sampled = NULL, iterations = NULL)

Arguments

filename

The filename used by the estimate function.

total

An object of class Counts giving the size of the population for which the finite-population estimates are to be generated.

sampled

An object of class Counts giving the same of the sample from which the rates, means, or probabilities were estimated. If no sampled argument is supplied, and if the model includes an exposure term, then sampled is assumed to equal exposure.

iterations

A vector of positive integers giving the iterations to be extracted if an item has multiple iterations.

Details

Consider a model in which

y_i \sim G(\gamma_i, n_i)

for some distribution G, such as a Poisson, binomial, or normal distribution. y_i is a count or other value for cell i within a classification defined by dimensions such as age and sex. \gamma_i is an unobserved cell-level parameter such as a rate, probability, or mean. n_i is a cell-level exposure or sample size, which is included in some models, such as Poisson or binomial models, but not all.

We assume that y_i is observed for only part of the population (the sampled population), and would like to know Y_i, the corresponding value for the total population. This requires estimating values for the unobserved' part of the population (the nonsampled population). We assume that the unobserved part of the population is subject to the same \gamma_i as the observed part.

Quantities y_i and Y_i are finite-population quantities, that is, they are values that are, or could theoretically be, observed in real populations. Value \gamma_i, in contrast, is a super-population quantity. It describes the hypothetical super-population from which values such as y_i and Y_i are drawn.

References

Gelman, A., Carlin, J.B., Stern, H.S. and Rubin, D.B., 2014. Bayesian Ddata Analysis. Third Edition. Boca Raton, FL, USA: Chapman & Hall/CRC. Section 8.3.

See Also

finiteY can be used with the results from a call to estimate or predict functions such as estimateModel and predictModel.

Examples

## generate sampled, non-sampled, and total population
popn.sampled <- Counts(array(rpois(n = 20, lambda = 100),
                             dim = c(10, 2),
                             dimnames = list(region = LETTERS[1:10],
                                 sex = c("Female", "Male"))))
popn.nonsampled <- Counts(array(rpois(n = 20, lambda = 900),
                             dim = c(10, 2),
                             dimnames = list(region = LETTERS[1:10],
                                 sex = c("Female", "Male"))))
popn.total <- popn.sampled + popn.nonsampled

## binomial model
y.sampled.binom <- Counts(array(rbinom(n = 20, size = popn.sampled, prob = 0.5),
                          dim = c(10, 2),
                          dimnames = list(region = LETTERS[1:10],
                              sex = c("Female", "Male"))))
filename.binom <- tempfile()
estimateModel(Model(y ~ Binomial(mean ~ region + sex)),
              y = y.sampled.binom,
              exposure = popn.sampled,
              filename = filename.binom,
              nBurnin = 10,
              nSim = 10,
              nChain = 2)
fy.binom <- finiteY(filename = filename.binom, # sample population assumed
                    total = popn.total)        # to equal exposure

## normal model
y.sampled.norm <- Counts(array(rnorm(n = 20),
                               dim = c(10, 2),
                               dimnames = list(region = LETTERS[1:10],
                                   sex = c("Female", "Male"))))
filename.norm <- tempfile()
estimateModel(Model(y ~ Normal(mean ~ region + sex)),
              y = y.sampled.norm,
              filename = filename.norm,
              nBurnin = 10,
              nSim = 10,
              nChain = 2)
fy.norm <- finiteY(filename = filename.norm,
                   sampled = popn.sampled, # specify sample population
                   total = popn.total)

StatisticsNZ/demest documentation built on Nov. 2, 2023, 7:56 p.m.