# Difference of Two Proportions Hypothesis Test with Weighted Sample Data

I have survey data which contain respondents' answers to several questions. As the survey contained a disproportionate number of people from certain demographic groups, the survey results are weighted by race, sex and age.

I have responses to the same questions for two years (eg. 2016 and 2017), and am trying to find out if the proportion of people who responded "yes" to a particular question has fallen. That is, I have calculated the weighted agreement rate to the question in 2016 (p1) and the weighted agreement rate to the question in 2017 (p2), and am trying to see if p1 - p2 = 0.

The simple hypothesis test for a difference between two proportions is well known (described at https://onlinecourses.science.psu.edu/stat414/node/268). However, I am wondering if:

1) Weighting the samples by demographic variables has changed the standard error; thus, a more complicated hypothesis test formula is required. If so, what is this formula?

2) Whether there are other methods, other than applying this possibly more complicated formula, to rigorously test for a difference between the two proportions. For instance, are there non parametric hypothesis tests that can be used?

Of the existing packages, @ThomasLumley's library(survey) in R does the best job in accounting for calibration to demographics. Some combination of design declaration survey::surveydesign(), estimation survey::svymean() and producing a difference survey::svycontrast() should get you there.