calib_weights: Weights of the calibration estimator

Description Usage Arguments Details Value Examples

View source: R/NonProbEst.R

Description

Calculates the calibration weights from a disjunct matrix of covariates, a vector of population totals and a vector of initial weights.

Usage

1
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

1
2
3
4
5
6
7
8
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")

Example output

Loading required package: lattice
Loading required package: ggplot2
   [1] 49.28401 33.44086 56.42159 49.08121 49.21761 49.91921 36.42130 46.15820
   [9] 51.36408 33.29842 44.41849 32.73467 51.00355 32.73467 34.01677 34.82604
  [17] 53.00117 42.26352 36.73358 52.10386 38.49960 34.01677 36.26616 37.52604
  [25] 39.84286 54.52732 44.41849 49.49484 46.55397 39.00147 57.23421 45.25099
  [33] 62.06972 60.75895 49.71380 38.17230 47.32695 48.58427 34.30843 48.87214
  [41] 46.42495 41.58048 41.75836 37.28778 40.87652 53.68428 60.37317 48.79921
  [49] 39.84286 40.18448 38.01523 62.06972 36.11168 43.66648 51.00355 38.34118
  [57] 62.60191 53.00117 41.05139 50.34722 49.49484 51.00355 37.52604 62.06972
  [65] 56.02555 47.84008 45.57086 41.58048 41.19479 33.87187 49.07408 43.54547
  [73] 51.44085 33.44086 44.33003 49.29118 47.55829 50.35454 51.79695 34.60260
  [81] 52.77540 52.92207 33.44086 61.27990 45.37674 46.63033 53.83348 32.45639
  [89] 41.19479 44.29539 43.17528 42.99137 38.66992 57.23421 35.80469 45.83421
  [97] 49.08121 38.34118 42.99137 34.89928 40.52902 58.71906 56.66296 47.84008
 [105] 48.03775 37.69206 56.74765 50.13276 48.37732 56.26523 50.34722 40.35638
 [113] 35.04858 40.84458 52.77540 52.77540 54.06377 56.18126 54.84243 46.23392
 [121] 59.98581 36.42130 42.65922 48.65689 54.84243 37.84779 49.70657 48.03775
 [129] 48.44963 47.15399 50.24156 48.66396 43.02498 46.15820 47.83312 57.72494
 [137] 52.69664 56.02555 41.19479 52.32675 47.83312 46.82300 44.22928 33.15658
 [145] 42.62589 41.57444 39.50415 38.49960 46.56208 46.35566 52.24866 38.34118
 [153] 56.99041 44.29539 59.47586 40.87652 57.97188 46.42495 36.89072 42.08349
 [161] 47.43338 44.22928 46.75312 49.42097 55.23010 48.17125 43.85328 49.92647
 [169] 54.76058 53.68428 33.44086 56.90536 49.00796 32.59523 32.31813 45.44456
 [177] 36.57711 52.32675 56.50592 42.56227 41.37101 36.57711 50.78629 48.66396
 [185] 37.36620 49.70657 49.21046 43.95317 49.28401 53.14847 42.99137 45.96159
 [193] 41.54799 46.22719 40.84458 47.02330 47.43338 48.44963 36.89609 33.01534
 [201] 43.95317 50.13276 47.03014 50.35454 32.73467 46.22719 37.69206 49.92647
 [209] 54.29505 33.58392 48.03775 43.20904 54.29505 45.28151 60.50014 34.45520
 [217] 39.00147 49.49484 43.95317 44.67518 46.82300 48.44963 33.29842 40.96523
 [225] 48.24325 51.66091 33.87187 36.42130 48.66396 56.50592 50.13276 41.75836
 [233] 44.60851 40.35638 55.78690 45.57086 51.68825 33.29842 49.49484 34.16229
 [241] 37.20703 39.83707 50.13276 47.96606 49.71380 53.45561 39.00147 44.41849
 [249] 33.87187 43.85328 39.50415 56.74765 46.82981 48.03775 43.35998 59.47586
 [257] 42.65922 44.41849 57.39327 38.34118 54.29505 39.67314 41.75836 44.10671
 [265] 51.58381 37.20703 45.37674 34.01677 49.50204 44.29539 49.63961 49.63961
 [273] 54.76058 36.89609 55.78690 51.35662 52.10386 46.62355 44.29539 50.70312
 [281] 45.05823 49.00796 35.65217 53.37583 52.92207 56.74765 49.21761 38.49960
 [289] 53.68428 40.35638 58.71906 51.36408 54.84243 40.52902 39.66738 49.00796
 [297] 43.57952 45.93368 43.95317 48.25026 44.60851 56.74765 43.48048 53.00117
 [305] 50.35454 50.56996 49.28401 50.14005 41.84169 39.00147 35.34909 52.32675
 [313] 48.79921 37.69206 44.99099 51.80448 51.88191 48.45667 54.14458 38.83534
 [321] 37.53150 48.48751 53.83348 47.15399 57.72494 51.00355 35.88239 49.91921
 [329] 50.13276 50.35454 59.73030 32.18047 33.87187 56.50592 37.21244 54.37620
 [337] 37.68658 45.18345 54.29505 51.00355 56.99041 40.52902 43.91883 57.72494
 [345] 41.01931 43.35998 36.73358 55.54927 49.42816 44.10671 47.22446 36.89072
 [353] 32.87471 58.71906 38.17230 47.83312 33.44086 50.14005 50.92743 47.23133
 [361] 59.47586 40.18448 40.84458 41.22700 57.97188 48.25026 37.05393 59.47586
 [369] 33.72759 35.80469 48.25026 35.50030 41.05139 49.91921 51.14529 57.47905
 [377] 47.22446 37.04854 33.72759 55.94194 57.63879 50.77891 52.24866 49.07408
 [385] 58.46893 55.07704 52.55060 33.44086 32.59523 49.92647 42.99137 48.03775
 [393] 47.83312 49.63961 43.95317 55.94194 38.50519 39.84286 42.80824 51.66091
 [401] 44.04088 39.84286 45.18345 43.39388 54.60088 33.15658 54.37620 37.85330
 [409] 47.35571 49.08121 47.06007 49.42816 35.50030 42.44432 48.24325 41.22700
 [417] 34.75062 46.62355 52.99347 49.21761 35.04858 52.69664 50.92743 50.14005
 [425] 53.14847 44.33003 48.03775 40.52902 38.33560 59.98581 51.88191 50.92743
 [433] 52.31914 43.35998 45.83421 44.60851 49.92647 39.16262 52.10386 50.99613
 [441] 46.13018 54.84243 49.21046 48.65689 46.15820 49.71380 36.89072 39.33588
 [449] 56.02555 51.14529 42.44432 32.18047 34.01677 44.10671 56.02555 47.02330
 [457] 38.34118 50.06522 32.45639 54.76058 50.92743 47.02330 38.00970 43.73175
 [465] 35.95786 34.75062 38.99580 45.18345 37.85330 51.88191 57.63879 43.91883
 [473] 60.24243 33.15658 55.78690 43.54547 47.02330 47.62937 53.60417 44.29539
 [481] 47.15399 41.19479 37.69206 44.41849 47.02330 49.84471 42.38097 51.14529
 [489] 34.75062 48.37732 49.71380 54.76058 37.53150 42.29657 43.29527 57.72494
 [497] 50.77891 38.83534 49.07408 49.71380 46.35566 45.25099 41.22700 38.17785
 [505] 43.17528 59.26247 40.87652 54.36830 41.75836 48.24325 47.42648 40.84458
 [513] 43.29527 33.72759 32.45639 43.57318 45.57086 51.22173 44.22928 40.84458
 [521] 38.66992 56.66296 34.01677 47.83312 42.44432 50.78629 41.54799 38.49960
 [529] 45.67466 46.55397 48.24325 60.50014 56.99041 48.45667 55.70365 41.19479
 [537] 46.75312 58.71906 56.26523 57.47905 44.48488 33.15658 51.00355 45.76581
 [545] 42.80824 62.06972 40.18448 41.66346 53.45561 42.44432 51.43338 50.56996
 [553] 43.91883 39.66738 54.84243 48.17125 33.72759 47.02330 47.36259 33.58392
 [561] 47.42648 38.83534 49.07408 37.84779 50.56260 53.60417 49.91921 42.44432
 [569] 50.06522 35.04858 41.90423 61.80532 33.29842 46.35566 52.54296 58.46893
 [577] 48.25026 54.29505 47.76174 59.22252 43.29527 60.50014 58.46893 37.04854
 [585] 55.31265 51.88191 32.73467 33.15658 51.36408 48.79921 45.63897 39.00147
 [593] 47.76174 43.17528 46.15820 35.65217 45.83421 55.78690 46.62355 53.91394
 [601] 50.78629 46.06628 54.60882 43.85328 50.14005 47.15399 38.83534 37.36620
 [609] 48.44963 50.34722 44.41849 48.17125 39.16262 33.72759 41.22700 33.72759
 [617] 39.00147 55.31265 49.84471 50.14005 42.92721 47.42648 52.09628 37.53150
 [625] 43.35998 53.37583 54.99484 51.22173 53.60417 50.78629 41.93700 44.33003
 [633] 53.91394 43.39388 44.29539 45.83421 56.74765 46.75312 53.91394 38.01523
 [641] 38.50519 45.44456 53.00117 48.24325 44.67518 53.91394 54.29505 50.14005
 [649] 54.29505 53.14847 41.93700 38.66429 57.23421 44.79934 56.18126 39.16262
 [657] 54.99484 48.66396 35.19851 43.39388 38.66992 51.22173 53.91394 56.26523
 [665] 45.76581 49.21761 40.87652 49.21761 42.02068 37.52604 34.75062 42.08349
 [673] 44.51967 56.02555 43.39388 40.79073 49.42816 38.01523 50.56996 47.83312
 [681] 56.74765 41.40336 49.91921 34.89928 37.52604 50.78629 32.31813 38.66992
 [689] 49.07408 54.84243 46.75312 43.76595 48.79211 49.63961 46.62355 49.49484
 [697] 47.62937 40.01330 55.94194 46.82300 37.68658 41.05139 44.86630 35.80469
 [705] 46.42495 44.67518 44.67518 48.17125 36.11168 42.80824 49.49484 42.29657
 [713] 47.03014 36.11168 53.60417 42.44432 45.18345 48.58427 35.95786 39.50415
 [721] 51.68825 57.88536 37.84779 56.50592 52.77540 50.56996 43.17528 40.84458
 [729] 45.67466 50.77891 45.44456 58.71906 54.99484 49.29118 41.05139 36.57711
 [737] 43.29527 49.42097 43.17528 53.00117 57.72494 56.50592 39.00147 47.02330
 [745] 56.99041 46.82981 43.73175 52.24106 37.84779 43.29527 35.04858 40.18448
 [753] 35.50030 37.85330 38.49960 43.73175 32.73467 46.22719 47.93693 46.82300
 [761] 40.52902 40.00749 38.17230 42.44432 55.70365 48.17125 44.04088 44.14120
 [769] 57.97188 60.75895 41.40336 58.21987 38.00970 49.49484 39.49841 53.22790
 [777] 50.35454 48.37732 34.45520 49.49484 54.37620 48.58427 57.47905 51.21429
 [785] 43.54547 37.69206 37.36620 46.95313 35.04858 34.45520 40.18448 46.95313
 [793] 49.42816 45.63897 48.17125 42.65922 33.01534 39.84286 52.01853 38.83534
 [801] 42.29657 37.37163 52.24866 58.46893 40.35638 41.22700 38.66992 51.00355
 [809] 34.45520 50.14005 47.83312 52.32675 45.83421 52.10386 51.88191 51.79695
 [817] 40.70240 37.37163 47.83312 34.75062 38.00970 45.76581 46.92462 44.33003
 [825] 38.50519 41.58048 51.66091 41.90423 62.86971 43.91883 43.95317 52.77540
 [833] 44.29539 41.22700 42.62589 43.85328 53.00117 33.87187 33.87187 41.40336
 [841] 41.30927 50.56996 49.50204 54.84243 52.99347 47.62937 41.54799 51.35662
 [849] 33.87187 52.69664 55.07704 49.08121 49.49484 35.34909 45.57086 48.87214
 [857] 54.60882 43.02498 36.42130 51.88191 50.34722 40.78362 51.88191 37.04854
 [865] 42.20044 46.03028 36.26616 48.17125 54.84243 43.02498 49.63239 49.00084
 [873] 47.83312 38.17785 52.10386 56.50592 40.52902 36.26616 54.37620 41.37101
 [881] 53.22017 53.14847 47.63630 45.63897 59.47586 57.63879 36.42130 62.33524
 [889] 46.63033 33.44086 50.99613 41.40336 49.49484 59.64115 42.47751 58.13299
 [897] 42.11640 57.72494 49.70657 57.39327 55.78690 40.17863 35.65217 54.60882
 [905] 49.85196 57.47905 53.14847 50.56996 52.32675 35.50030 52.55060 33.44086
 [913] 36.73892 46.55397 41.58048 35.65217 50.35454 38.49960 43.35998 41.01931
 [921] 49.42097 48.65689 36.57711 36.57711 42.44432 50.34722 45.44456 52.31914
 [929] 59.22252 37.53150 40.18448 47.42648 37.53150 53.45561 44.48488 52.47217
 [937] 35.34909 44.60851 51.43338 56.74765 60.75895 52.10386 38.66992 56.02555
 [945] 55.31265 50.92743 44.29539 40.52902 51.65340 50.35454 33.29842 56.02555
 [953] 53.68428 57.23421 39.84286 47.23133 58.71906 45.18345 52.76773 49.50204
 [961] 56.74765 37.68658 49.49484 46.62355 38.34118 56.26523 51.66091 60.24243
 [969] 43.54547 54.84243 56.18126 35.65217 33.87187 52.55060 39.50415 50.35454
 [977] 56.74765 47.83312 37.85330 49.71380 43.48048 55.54927 44.67518 47.43338
 [985] 50.13276 48.25026 41.58048 56.02555 47.16221 52.24866 35.19851 61.54205
 [993] 47.83312 34.75062 43.95317 46.42495 47.23133 47.66661 37.52604 51.87437

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