Learn R Programming

spsurvey (version 4.0.0)

adjwgt: Adjust Survey Design Weights by Categories

Description

Purpose of this function is to adjust initial survey design weights when implementation results in use of oversample sites or when it is desired to have final weights sum to known frame size. Adjusted weights are equal to initial weight * framesize/sum(initial weights). The adjustment is done separately for each category specified in wtcat.

Usage

adjwgt(sites, wgt, wtcat, framesize)

Arguments

sites

Vector of the logical value for each site, where TRUE = include the site and FALSE = do not include the site.

wgt

Vector of the initial weight (inverse of the sample inclusion probability) for each site.

wtcat

Vector of the weight adjustment category name for each site.

framesize

Vector of 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

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
# NOT RUN {
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(15, 10)
names(framesize) <- c("A","B")
adjwgt(sites, wgt, wtcat, framesize)

# }

Run the code above in your browser using DataLab