When calculating a difference in two proportions I've seen that you can use the svyglm function in the survey package (gaussian family) to fit the model. Is there a way to obtain wilson 95% CIs for difference in proportions for survey weighted data?
I tried the following:
svy_design <- svydesign(ids = ~block, strata = ~strata_study, weights = ~wt, data = data, nest = TRUE, fpc = NULL)
model <- svyglm(as.numeric(binary_outcome)~binary_exposure, design=svy_design)
I got the following result:
Call:
svyglm(formula = as.numeric(binary_outcome) ~ binary_exposure,
design = svy_design, data = data)
Survey design:
svydesign(ids = ~block, strata = ~strata_study, weights = ~wt,
data = data, nest = TRUE, fpc = NULL)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.014101 0.003891 260.614 <2e-16 ***
binary_exposure 0.059430 0.039972 1.487 0.139
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for gaussian family taken to be 0.01723948)
Number of Fisher Scoring iterations: 2
confint(model)
2.5 % 97.5 %
(Intercept) 1.0064246 1.0217782
binary_exposure -0.0194294 0.1382897
For the chi2 test:
svychisq(~binary_outcome+binary_exposure,design = svy_design, statistic="F")
The result as follows:
Pearson's X^2: Rao & Scott adjustment
data: svychisq(~binary_outcome + binary_exposure, design = svy_design, statistic = "F")
F = 8.5087, ndf = 1, ddf = 200, p-value = 0.003938
The pvalues and 95% CI don't seem to match up.
How do you generate wilson 95% CI for a difference in proportions for survey weighted data?