Closed dtburk closed 4 months ago
Sep 1, 2020 @mhut214:
Hey Greg, thanks for providing this. Any insight into the Fay method used in IPUMS USA srvyr example. Is this mimicking the successive difference method? When I attempt the method you have outlined, I get very large standard errors. Any help would be appreciated!
Sep 3, 2020 @gergness:
Hm, nothing stands out. I'm pretty sure I checked that the results matched between R and Stata when making that, but no longer have access to Stata. I'd recommend posting on the ipums forum or email ipums@umn.edu with a small example of something you're trying to calculate and seeing if it matches what they get in another statistical package.
These pages have now all been updated to include example R code:
IPUMS CPS replicate weights: https://cps.ipums.org/cps/repwt.shtml IPUMS USA replicate weights: https://usa.ipums.org/usa/repwt.shtml IPUMS NHIS variance estimation: https://nhis.ipums.org/nhis/userNotes_variance.shtml
May 14, 2019 @gergness:
When I was first writing ipumsr I did some work translating the stata code on static pages of ipums.org to explain how to use survey weight variables. It's always been on my todo list to help projects update, but I never did get around to it.
Yesterday, two IPUMS users on twitter were talking about this: https://twitter.com/surlyurbanist/status/1127968834902605825
To make sure it doesn't get lost, here's the translation of CPS, USA & NHIS user notes on weights for R.
CPS - Replicate Weights
Adapted from https://cps.ipums.org/cps/repwt.shtml
IS THERE ANY WAY TO DO THIS AUTOMATICALLY IN MAJOR STATISTICAL PACKAGES?
In R, the survey package (and the srvyr package, which is based on the survey package) set up an object with the survey weighting information for you.
R (survey package)
R (srvyr package)
After setting up the svy object, we can now use it to perform weighted calcuations. For example, to calculate the mean of a variable named VAR1:
R (survey package)
R (srvyr package)
And we need to be careful to subset the replicate weights when subsetting. For example, if we wanted to subset to persons aged 25-64, we would run this command:
R (survey package)
R (srvyr package)
USA - Replicate weights
Adapted from: https://usa.ipums.org/usa/repwt.shtml
IS THERE ANY WAY TO DO THIS AUTOMATICALLY IN MAJOR STATISTICAL PACKAGES?
In R, the survey package (and the srvyr package, which is based on the survey package) set up an object with the survey weighting information for you.
R (survey package)
R (srvyr package)
After setting up the svy object, we can now use it to perform weighted calcuations. For example, to calculate the mean of a variable named VAR1:
R (survey package)
R (srvyr package)
And we need to be careful to subset the replicate weights when subsetting. For example, if we wanted to subset to persons aged 25-64, we would run this command:
R (survey package)
R (srvyr package)
IPUMS NHIS
Adapted from https://nhis.ipums.org/nhis/userNotes_variance.shtml
General Syntax to Account for Sample Design
The following general syntax will allow users to account for sampling weights and design variables when using STATA, SAS, SAS-callable SUDAAN, or R (through the survey or srvyr package) to estimate, for example, means using IPUMS NHIS data.
...
R (survey)
R (srvyr)
Subsetting IPUMS NHIS Data
...
R (survey)
R (srvyr)