I have been looking at how to calculate the CI for proportions across two categorical variables. I have seen this answer, which gets close to what I am looking for, but I am wanting the proportions to be calculated between all possible combinations of the two variables. I have gotten it to work using svymeans
and confint
and this is the output I am looking for, but using svyciprop
. This example comes from the api data in the survey package using the apiclus1 data frame.
library(survey)
data(api)
dclus1<-svydesign(id=~dnum, fpc=~fpc, data=apiclus1)
cbind(svymean(~interaction(sch.wide, stype), design = dclus1),
confint(svymean(~interaction(sch.wide, stype), design = dclus1)))
2.5 % 97.5 %
interaction(sch.wide, stype)No.E 0.06557377 0.031454436 0.09969311
interaction(sch.wide, stype)Yes.E 0.72131148 0.635732262 0.80689069
interaction(sch.wide, stype)No.H 0.01639344 -0.002458860 0.03524575
interaction(sch.wide, stype)Yes.H 0.06010929 0.018347771 0.10187081
interaction(sch.wide, stype)No.M 0.04371585 0.005196326 0.08223537
interaction(sch.wide, stype)Yes.M 0.09289617 0.050121072 0.13567128