model_assisted: Calculates a model assisted estimation

Description Usage Arguments Details Value References Examples

View source: R/NonProbEst.R

Description

It uses the model assisted estimator introduced by Särndal et al. (1992).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
model_assisted(
  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

Särndal, C. E., Swensson, B., & Wretman, J. (1992). Model assisted survey sampling. Springer, New York.

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_assisted(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] 4926.614

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