Adjust initial survey design weights so that the
final weights sum to a desired frame size. Adjusted weights
proportionally scale the initial weights to sum to the desired frame size.
Separate adjustments are applied to each category specified in wgtcat
.
adjwgt(wgt, wgtcat = NULL, framesize, sites = NULL)
Vector of initial weights for each site. These equal the reciprocal of the site's inclusion probability.
Vector containing each site's weight adjustment
category name. The default is NULL
, which assumes every
site is in the same category.
Vector containing the known size of the frame
for each category name in wgtcat
. If wgtcat
is provided,
the names in framesize
must match the names in wgtcat
.
If wgtcat
is not provided, an unnamed scalar is given to
framesize
.
Vector indicating site use; TRUE
indicates the site
should be included in the weight adjustment and FALSE
indicates
the site should not be included in the weight adjustment. The default is
NULL
, which assumes every site should be included.
Vector of adjusted weights, where the adjusted weight is set
to 0
for sites whose value in the sites argument was set to
FALSE
.
wgt <- runif(50)
wgtcat <- rep(c("A", "B"), c(30, 20))
framesize <- c(A = 15, B = 10)
sites <- rep(rep(c(TRUE, FALSE), c(9, 1)), 5)
adjwgt(wgt, wgtcat, framesize, sites)
#> [1] 0.106022955 1.095458863 0.788784344 0.206410837 0.009715285 0.612363250
#> [7] 0.653569531 0.380457302 0.962256116 0.000000000 1.148329267 0.229692762
#> [13] 0.044958032 0.420658625 0.528247132 0.256909705 0.529835674 0.083585936
#> [19] 0.510355313 0.000000000 0.380621490 0.890696902 0.965456641 0.257286396
#> [25] 1.287424600 0.973599623 0.067547702 0.696155991 0.913599727 0.000000000
#> [31] 0.031186232 0.225244066 0.300406067 0.635566997 0.478348221 0.431561081
#> [37] 0.705436433 0.947237293 0.180084150 0.000000000 0.679202604 0.498141297
#> [43] 0.640773369 0.659352102 0.095888583 0.764519223 0.768588110 0.989313538
#> [49] 0.969150636 0.000000000