I have a survey design with 12 strata and have the marginal distributions of the post-stratification variables for each stratum. I am calling the rake function in the
survey package as follows:
the_design = svydesign(ids=~SID, strata=~Stratum, weights=~Baseweight, data=my_data) raked_design = rake(design=the_design , sample.margins=list(~Stratum+Annual_Income), population.margins = list(income_frequencies))
However this code produces the following error:
Error in postStratify.survey.design(design, strata[[i]], population.margins[[i]], : Stratifying variables don't match
I believe this is telling me that I need to change
income_frequencies which is a data.frame that looks like this:
HHI_lt75K HHI_gt75K 0 7.116883 11.038961 1 4.218109 10.173087 2 17.362333 10.796333 3 6.333889 9.296901 ...
and where row.names='Stratum' for this data.frame.
Unfortunately I do not know
- If this truly is what the error message is telling me, and
- If this is what the error message is telling me, what I need to change.