calib_weights {NonProbEst} | R Documentation |
Weights of the calibration estimator
Description
Calculates the calibration weights from a disjunct matrix of covariates, a vector of population totals and a vector of initial weights.
Usage
calib_weights(Xs, totals, initial_weights, N, ...)
Arguments
Xs |
Matrix of calibration variables. |
totals |
A vector containing population totals for each column (class) of the calibration variables matrix. |
initial_weights |
A vector containing the initial weights for each individual. |
N |
Integer indicating the population size. |
... |
Further arguments to be passed to the 'calib' function from the 'sampling' package. |
Details
The function uses the 'calib' function from the 'sampling' package for the estimation of g-weights, which are multiplied by the initial weights to obtain the final calibration weights. The initial weights can be calculated previously from the propensities for any of the implemented methods (see functions lee_weights
, sc_weights
, valliant_weights
, vd_weights
). The population size is used to scale said initial weights so they are easier to calibrate.
Value
A vector with the corresponding weights.
Examples
n = nrow(sampleNP)
N = 50000
language_total = 45429
covariates = c("education_primaria", "education_secundaria",
"age", "sex")
pi = propensities(sampleNP, sampleP, covariates, algorithm = "glm", smooth = FALSE)
wi = sc_weights(pi$convenience)
calib_weights(sampleNP$language, language_total, wi, N, method = "raking")