View source: R/svymean_ratio.R
| svymean_ratio | R Documentation |
Robust ratio predictor (M-estimator) of the population mean and total with Huber and Tukey biweight (bisquare) psi-function.
svytotal_ratio(object, total, variance = "wu", keep_object = TRUE, ...)
svymean_ratio(object, total, N = NULL, variance = "wu",
keep_object = TRUE, N_unknown = FALSE, ...)
object |
an object of class |
total |
|
N |
|
variance |
|
keep_object |
|
N_unknown |
|
... |
additional arguments (currently not used). |
Package survey must be attached to the search path in order to use
the functions (see library or require).
The (robust) ratio predictor of the population total or mean is computed in two steps.
Step 1: Fit the ratio model associated with the predictor
by one of the functions svyratio_huber
or svyratio_tukey. The fitted model is called
object.
Step 2: Based on the fitted model obtained in the first step,
we predict the population total and mean, respectively, by
the predictors svytotal_ratio and svymean_ratio,
where object is the fitted ratio model.
Two types of auxiliary variables are distinguished: (1)
population size N and (2) the population total of the
auxiliary variable (denominator) used in the ratio model.
The option N_unknown = TRUE can be used in the predictor
of the population mean if N is unknown.
Three variance estimators are implemented (argument
variance): "base", "wu", and "hajek".
These estimators correspond to the estimators v0, v1,
and v2 in Wu (1982).
The return value is an object of class svystat_rob.
Thus, the utility functions summary,
coef,
SE,
vcov,
residuals,
fitted, and
robweights are available.
Object of class svystat_rob
Wu, C.-F. (1982). Estimation of Variance of the Ratio Estimator. Biometrika 69, 183–189.
Overview (of all implemented functions)
svymean_reg and svytotal_reg for (robust) GREG
regression predictors
svyreg_huberM, svyreg_huberGM,
svyreg_tukeyM and svyreg_tukeyGM for robust
regression M- and GM-estimators
svymean_huber, svytotal_huber,
svymean_tukey and svytotal_tukey for
M-estimators
head(workplace)
library(survey)
# Survey design for stratified simple random sampling without replacement
dn <- if (packageVersion("survey") >= "4.2") {
# survey design with pre-calibrated weights
svydesign(ids = ~ID, strata = ~strat, fpc = ~fpc, weights = ~weight,
data = workplace, calibrate.formula = ~-1 + strat)
} else {
# legacy mode
svydesign(ids = ~ID, strata = ~strat, fpc = ~fpc, weights = ~weight,
data = workplace)
}
# Robust ratio M-estimator with Huber psi-function
rat <- svyratio_huber(~payroll, ~ employment, dn, k = 5)
# Summary of the ratio estimate
summary(rat)
# Diagnostic plots of the ration/regression M-estimate (e.g.,
# standardized residuals against fitted values)
plot(rat, which = 1L)
# Plot of the robustness weights of the ratio/regression M-estimate
# against its residuals
plot(residuals(rat), robweights(rat))
# Robust ratio predictor of the population mean
m <- svymean_ratio(rat, total = 1001233, N = 90840)
m
# Summary of the ratio estimate of the population mean
summary(m)
# Extract estimate
coef(m)
# Extract estimate of scale
scale(m)
# Extract estimated standard error
SE(m)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.