Learn R Programming

spsurvey (version 5.5.1)

adjwgt: Adjust survey design weights by categories

Description

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.

Usage

adjwgt(wgt, wgtcat = NULL, framesize, sites = NULL)

Value

Vector of adjusted weights, where the adjusted weight is set to 0 for sites whose value in the sites argument was set to

FALSE.

Arguments

wgt

Vector of initial weights for each site. These equal the reciprocal of the site's inclusion probability.

wgtcat

Vector containing each site's weight adjustment category name. The default is NULL, which assumes every site is in the same category.

framesize

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.

sites

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.

Author

Tony Olsen olsen.tony@epa.gov

Examples

Run this code
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)

Run the code above in your browser using DataLab