Learn R Programming

mase (version 0.1.2)

ratioEstimator: Compute a ratio estimator

Description

Calculates a ratio estimator for a finite population mean/proportion or total based on sample data collected from a complex sampling design and auxiliary population data.

Usage

ratioEstimator(y, x_sample, x_pop, data_type = "raw", pi = NULL,
  N = NULL, pi2 = NULL, var_est = FALSE, var_method = "lin_HB",
  B = 1000, strata = NULL)

Arguments

y

A numeric vector of the sampled response variable.

x_sample

A numeric vector of the sampled auxiliary variable.

x_pop

A numeric vector of population level auxiliary information. Must come in the form of raw data, population total or population mean.

data_type

A string that specifies the form of population auxiliary data. The possible values are "raw", "total" or "mean". If data_type = "raw", then x_pop must contain a numeric vector of the auxiliary variable for each unit in the population. If data_type = "total" or "mean", then contains either the population total or population mean for the auxiliary variable.

pi

A numeric vector of inclusion probabilities for each sampled unit in y. If NULL, then simple random sampling without replacement is assumed.

N

A numeric value of the population size. If NULL, it is estimated with the sum of the inverse of the pis.

pi2

A square matrix of the joint inclusion probabilities. Needed for the "lin_HT" variance estimator.

var_est

A logical indicating whether or not to compute a variance estimator. Default is FALSE.

var_method

The method to use when computing the variance estimator. Options are a Taylor linearized technique: "lin_HB"= Hajek-Berger estimator, "lin_HH" = Hansen-Hurwitz estimator, "lin_HTSRS" = Horvitz-Thompson estimator under simple random sampling without replacement, and "lin_HT" = Horvitz-Thompson estimator or a resampling technique: "bootstrap_SRS" = bootstrap variance estimator under simple random sampling without replacement. The default is "lin_HB".

B

The number of bootstrap samples if computing the bootstrap variance estimator. Default is 1000.

strata

A factor vector of the stratum membership. If NULL, all units are put into the same stratum. Must have same length as y.

Value

A list of output containing:

  • pop_total: Estimate of population total

  • pop_mean: Estimate of the population mean

  • pop_total_var: Estimated variance of population total estimate

  • pop_mean_var: Estimated variance of population mean estimate

  • weights: Survey weights produced by ratio estimator

References

coc77mase sar92mase

See Also

greg for a linear or logistic regression model.

Examples

Run this code
# NOT RUN {
library(survey)
data(api)
ratioEstimator(y = apisrs$api00, x_sample = apisrs$meals, 
x_pop = sum(apipop$meals), data_type = "total", pi = apisrs$pw^(-1), 
N = dim(apipop)[1])

# }

Run the code above in your browser using DataLab