Learn R Programming

svyweight

Quick and Flexible Survey Weighting

Ben Mainwaring

Description

R package for quickly and flexibly calculating rake weights (also known as rim weights, or iterative proportional fitting). This allows post-stratification/non-response weighting on multiple variables, even the interlocked distribution of the two variables is not known. Interacts with Thomas Lumley's survey package, and adds additional functionality, more adaptable syntax, and error-checking to the weighting functionality in survey.

The core function in svyweight is rakesvy (and the related rakew8), which calculates post-stratification weights for a dataset or svydesign object, given targets. The command is designed to make weighting as simple as possible, with the following features:

  • Imputing unknown (NA) targets based on observed distributions
  • Accepting targets of 0 (equivalent to dropping cases from analysis)
  • Assessing weight quality using Kish' effective sample size
  • Weighting to either counts or percentage targets
  • Allowing specification of targets as vectors, matrices, or data frames
  • Allowing targets to be quickly rebased to a specified sample size
  • Flexibly matching targets to the correct variables in a dataset
  • Dynamically specifying weight targets based on recodes of variables in observed data

More details about the package are available in the R help files (see package?svyweight in R).

Planned Features

The package is under development, and additional features are planned for future release. This includes:

  • Additional metrics of weight quality
  • Techniques for weighting numeric and ordinal data based on histograms/binning

Contributions to the package, or suggestions for additional features, are gratefully accepted via email or GitHub.

Copy Link

Version

Install

install.packages('svyweight')

Monthly Downloads

161

Version

0.1.0

License

GPL-3

Maintainer

Ben Mainwaring

Last Published

May 3rd, 2022

Functions in svyweight (0.1.0)

gles17

Partial Data from the 2017 German Election Survey
as.w8margin

Weight Margin Objects
rakesvy

Flexibly Calculate Rake Weights
w8margin_matched

Check if w8margin Matches Observed Data
impute_w8margin

Impute NAs in w8margin Object
eff_n

Effective Sample Size and Weighting Efficiency
svyweight

svyweight: Quick and Flexible Rake Weighting