Learn R Programming

spsurvey (version 3.1)

adjwgt: Adjust Initial Survey Design Weights

Description

This function adjusts initial survey design weights when implementation results in use of oversample sites or when it is desired to have final weights sum to a known frame size. Adjusted weights are equal to initial weight times the frame size divided by the sum of the initial weights. The adjustment is done separately for each category specified in argument wtcat.

Usage

adjwgt(sites, wgt, wtcat, framesize)

Arguments

sites
the logical value for each site, where TRUE = include the site and FALSE = do not include the site.
wgt
the initial weight (inverse of the sample inclusion probability) for each site.
wtcat
the weight adjustment category name for each site.
framesize
the known size of the frame for each category name in wtcat, which must have the names attribute set to match the category names used in wtcat.

Value

A vector of adjusted weights, where the adjusted weight is set to zero for sites that have the logical value in the sites argument set to FALSE.

Examples

Run this code
sites <- as.logical(rep(rep(c("TRUE","FALSE"), c(9,1)), 5))
wgt <- runif(50, 10, 100)
wtcat <- rep(c("A","B"), c(30, 20))
framesize <- c(1650, 1100)
names(framesize) <- c("A","B")
adjwgt(sites, wgt, wtcat, framesize)

Run the code above in your browser using DataLab