# What R package is needed for IPUMS USA for weighting? Is it "survey"? Do you have sample code?

**URL:** <https://forum.ipums.org/t/what-r-package-is-needed-for-ipums-usa-for-weighting-is-it-survey-do-you-have-sample-code/2439>\
**Category:** USA\
**Created:** [July 11, 2018, 11:59pm UTC](https://forum.ipums.org/t/what-r-package-is-needed-for-ipums-usa-for-weighting-is-it-survey-do-you-have-sample-code/2439 "2018-07-11T23:59:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![madoolsy](https://avatars.discourse-cdn.com/v4/letter/m/a87d85/32.png) [@madoolsy](https://forum.ipums.org/u/madoolsy)\
**Post date:** [July 11, 2018, 11:59pm UTC](https://forum.ipums.org/t/what-r-package-is-needed-for-ipums-usa-for-weighting-is-it-survey-do-you-have-sample-code/2439/1 "2018-07-11T23:59:00Z")

</div>

I don’t have the “strata” or “cluster” variables in my dataset. I want to do person level analysis. I am using an ACS 2012-2016 microsample.

---

<div class="post-metadata">

**Author:** ![grover](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.ipums.org/grover/32/5_2.png) [@grover](https://forum.ipums.org/u/grover)\
**Post date:** [July 13, 2018, 2:49pm UTC](https://forum.ipums.org/t/what-r-package-is-needed-for-ipums-usa-for-weighting-is-it-survey-do-you-have-sample-code/2439/2 "2018-07-13T14:49:00Z")

</div>

The [ipumsr](https://github.com/mnpopcenter/ipumsr) R package includes a few vignettes which can be accessed with the `vignette()` command like so: vignette(‘ipums’) (you can also see the contents in the files on the github page here: [https://github.com/mnpopcenter/ipumsr/blob/master/vignettes/ipums-cps.Rmd](https://github.com/mnpopcenter/ipumsr/blob/master/vignettes/ipums-cps.Rmd))  
Under the “grab bag” header there is a brief discussion of weights. the [survey package](http://r-survey.r-forge.r-project.org/survey/) is likely the most popular way to apply weights, and while [STRATA](https://usa.ipums.org/usa-action/variables/STRATA#description_section) and [CLUSTER](https://usa.ipums.org/usa-action/variables/CLUSTER#description_section) are available for many IPUMS USA datasets and can improve variance estimation, they are not required by the survey package, as you can see in these helpful examples from a [survey package vignette](http://r-survey.r-forge.r-project.org/survey/doc/survey.pdf).

I hope this helps!

---

<div class="post-metadata">

**Author:** ![madoolsy](https://avatars.discourse-cdn.com/v4/letter/m/a87d85/32.png) [@madoolsy](https://forum.ipums.org/u/madoolsy)\
**Post date:** [July 17, 2018, 8:24pm UTC](https://forum.ipums.org/t/what-r-package-is-needed-for-ipums-usa-for-weighting-is-it-survey-do-you-have-sample-code/2439/3 "2018-07-17T20:24:00Z")

</div>

In the “survey” vignette for R, it shows that you’re supposed to enter ID, weights, data set name, and fpc. In the example it shows the following:

dclus1 \<- svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc)

FPC is supposed to be the population size, but I do not have this variable in my dataset. When I tried the following, I got an error “object ‘fpc’ not found”:

ipums.design \<- svydesign(id = ~SERIAL, weights=~PERWT, data=data\_CA, fpc= ~fpc)

What variables should I be using for id and fpc?

---

<div class="post-metadata">

**Author:** ![JeffBloem](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.ipums.org/jeffbloem/32/40_2.png) [@JeffBloem](https://forum.ipums.org/u/JeffBloem)\
**Post date:** [July 18, 2018, 5:35pm UTC](https://forum.ipums.org/t/what-r-package-is-needed-for-ipums-usa-for-weighting-is-it-survey-do-you-have-sample-code/2439/4 "2018-07-18T17:35:00Z")

</div>

See [this answer](https://forum.ipums.org/t/does-anyone-have-sample-code-for-using-svydesign-function-in-r/2444/1) to a related question.
