sam: Sample from a sampling frame

Description Usage Arguments

Description

Generate a probability sample from a sampling frame

sam takes a sample size, a 'population' data frame, a formula specifying the count variable and stratification variable(s), an optional expression to select a subset of the population, relative sampling factor and the probability parameter for a binomial response. It generates a sample based on these parameters.

Usage

1
2
sam(N = 1, pop = popagetable, fmla = population ~ sex + age +
  raceethnicity + state, subset, fac, prob)

Arguments

N

sample size (default: 1)

pop

a data frame giving frequencies in each stratum defined by a combination of variables. The stratification can be finer than the stratification given in fmla (Default: popagetable)

fmla

a formula of the form count ~ a + ... + c where count is a variable in pop giving the population count in each row of pop and the right hand side of the formula identifies the variables used to aggregate pop to form a sampling frame (Default: population ~ sex + age + raceethnicity + state). The default aggregates over counties in the default value of pop

subset

an expression that selects a subset, e.g. state == 'AK' & age > '5 to 9 years' (Default: no subsetting)

fac

a data frame or a list of data frames whose variables include some subset of variables in the right hand side of fmla and a variable named fac giving relative sampling factors for each combination of values of the stratification variables. Omitted combinations of variables get a default relative sampling factor of 1. If fac is a list, the relative sampling factors from each element are multiplied.

prob

a data frame or a list of data frames similar to fac, except that a variable named prob is used to specify the binomial probability of a '1' in each stratum of respondents. If prob is a list, the probabilities from each data frame are combined by adding their logits.


gmonette/WWCa documentation built on May 17, 2019, 7:25 a.m.