model_based {NonProbEst}R Documentation

Calculates a model based estimation

Description

It uses the model based estimator. The idea in order to estimate the population total is to add the sample responses and the predicted responses for the individuals not contained in the sample. See for example Valliant et al. (2000).

Usage

model_based(
  sample_data,
  full_data,
  covariates,
  estimated_var,
  estimate_mean = FALSE,
  positive_label = NULL,
  algorithm = "glm",
  proc = NULL,
  ...
)

Arguments

sample_data

Data frame containing the sample.

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

Valliant, R., Dorfman, A. H., & Royall, R. M. (2000) Finite population sampling and inference: a prediction approach. Wiley, New York.

Examples

#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_based(sampleNP, population, covariates,
   "vote_gen", positive_label = 'T', algorithm = 'glmnet')

[Package NonProbEst version 0.2.4 Index]