It uses the model assisted estimator introduced by S<U+00E4>rndal et al. (1992).
model_assisted(
sample_data,
weights,
full_data,
covariates,
estimated_var,
estimate_mean = FALSE,
positive_label = NULL,
algorithm = "glm",
proc = NULL,
...
)
Data frame containing the sample.
Vector containing the sample weights.
Data frame containing all the individuals contained in the population.
String vector specifying the common variables to use for training.
String specifying the variable to estimate.
Boolean specifying whether the mean estimation should be returned. Otherwise, the total estimation is returned by default.
String specifying the label to be considered positive if the estimated variable is categorical. Leave it as the default NULL otherwise.
A string specifying which classification or regression model to use (same as caret's method).
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.
The population total estimation (or mean if specified by the `estimate_mean` parameter).
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`.
S<U+00E4>rndal, C. E., Swensson, B., & Wretman, J. (1992). Model assisted survey sampling. Springer, New York.
# NOT RUN {
#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')
# }
Run the code above in your browser using DataLab