Currently in version 0.70, the weights package in R provides basic tools for quickly analyzing survey data and producing weighted statistics.

Skip to content
# Weights

### Share this:

### Leave a Reply Cancel reply

by Josh Pasek

Currently in version 0.70, the weights package in R provides basic tools for quickly analyzing survey data and producing weighted statistics.

- Click to share on Facebook (Opens in new window)
- Click to share on Twitter (Opens in new window)
- Click to share on Reddit (Opens in new window)
- Click to share on Pinterest (Opens in new window)
- Click to share on Tumblr (Opens in new window)
- Click to share on LinkedIn (Opens in new window)
- Click to email this to a friend (Opens in new window)
- Click to print (Opens in new window)

Categories:

Tags:

No Tag

© 2021 Josh Pasek. Created for free using WordPress and
Colibri

## 3 Responses

Your weights package would be extremely useful to me – if there was documentation on how weighted statistics are calculated or at least references in the help documentation. My own code to produce weighted chi square tests of independence gives slightly different results than wtd.chi.sq(). I wrote the code using Dorofeev and Grant, “Statistics for Real-Life Sample Surveys”. I have no reference or formulas for your functions to compare them to my own.

I wonder what your weighted t-test is doing: I notice that your code doesn’t give the same answer for proportional weights. If you use the same data, but multiply the weights by some constant other than one, the p-value completely changes. That’s not what I would expect to see from a weighted analysis. What are the weights supposed to mean? Are they supposed to have mean equal to 1? If so, it would be nice if this were explained in the documentation.

The package is designed to calculate weights where N is equal to the sum of the weights. Hence, if the weights are not set to mean to 1, it will assume that the non-1 value is correct and will use that value. This is sometimes used for datasets where researchers catalog the number of cases with a particular set of values rather than using the weights to solely correct for demographic differences. I’ll try to add in a default option that sets the mean to 1 and allows researchers to turn that off in the next iteration.