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.006620736 0.073309846 0.864082196 0.199606423 0.556244620 1.140772402
#> [7] 1.051511478 0.556287607 0.873322282 0.000000000 1.135491447 0.240088460
#> [13] 0.301826224 1.170262970 0.485577078 0.823762985 0.025623222 0.239542816
#> [19] 0.027051464 0.000000000 0.971423261 1.143696090 0.220204810 0.645162024
#> [25] 0.632857303 0.071818203 0.099662452 0.484398260 0.959793342 0.000000000
#> [31] 1.057573347 0.709004596 1.039502335 1.030638690 0.114893617 1.184803869
#> [37] 0.343595618 0.483001105 0.488339185 0.000000000 0.455772868 1.066973356
#> [43] 0.071710181 1.195244333 0.034006027 0.018601238 0.119242042 0.009342650
#> [49] 0.577754943 0.000000000