model_calibrated: Calculates a model calibrated estimation

Description Usage Arguments Details Value References Examples

View source: R/NonProbEst.R

Description

It uses the model calibrated estimator introduced by Wu et al. (2001).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
model_calibrated(
  sample_data,
  weights,
  full_data,
  covariates,
  estimated_var,
  estimate_mean = FALSE,
  positive_label = NULL,
  algorithm = "glm",
  proc = NULL,
  ...
)

Arguments

sample_data

Data frame containing the sample.

weights

Vector containing the sample weights.

full_data

Data frame containing all the individuals contained in the population.

covariates

String vector specifying the common variables to use for training.

estimated_var

String specifying the variable to estimate.

estimate_mean

Boolean specifying whether the mean estimation should be returned. Otherwise, the total estimation is returned by default.

positive_label

String specifying the label to be considered positive if the estimated variable is categorical. Leave it as the default NULL otherwise.

algorithm

A string specifying which classification or regression model to use (same as caret's method).

proc

A string or vector of strings specifying if any of the data preprocessing techniques available in train function from 'caret' package should be applied to data prior to the propensity estimation. By default, its value is NULL and no preprocessing is applied.

...

Further parameters to be passed to the train function.

Details

Training of the models is done via the 'caret' package. The algorithm specified in algorithm must match one of the names in the list of algorithms supported by 'caret'.

Value

The population total estimation (or mean if specified by the 'estimate_mean' parameter).

References

Wu, C., & Sitter, R. R. (2001). A model-calibration approach to using complete auxiliary information from survey data. Journal of the American Statistical Association, 96(453), 185-193.

Examples

1
2
3
4
5
6
7
#Simple example
covariates = c("education_primaria", "education_secundaria",
   "age", "sex", "language")
if (is.numeric(sampleNP$vote_gen))
   sampleNP$vote_gen = factor(sampleNP$vote_gen, c(0, 1), c('F', 'T'))
model_calibrated(sampleNP, nrow(population) / nrow(sampleNP),
   population, covariates, "vote_gen", positive_label = 'T', algorithm = 'glmnet')

Example output

Loading required package: lattice
Loading required package: ggplot2
[1] 4941.118

NonProbEst documentation built on July 1, 2020, 6:08 p.m.