Search code examples
rsurveychi-squaredcontingency

how is obtained the observed cell counts in svychisq in R?


I'm using the function survey::svychisq() to test for independence in a two-way contingency table for complex samples.

With svytable() I get the observed counts considering the weights defined in design, and I would assume that the observed values saved in svychisq() objects would be the same, but they are not:

svytable(~row.var+col.var, design)
# 330.6634    867.6478    177.1630
# 687.4503    962.5404    228.2926

and

svychisq(~row.var+col.var, design)$observed
# 404.6712    1061.8411    216.8149
# 841.3126    1177.9722    279.3881

provide different results and I couldn't really understand why.

Could someone explain to me how the latter observed values are calculated?

Thanks!


Solution

  • The $observed component is a weighted table with weights scaled to sum to the sample size.