1

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!

MDSF
  • 123
  • 6

1 Answers1

1

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

Thomas Lumley
  • 1,893
  • 5
  • 8
  • Thank you for your answer! Given that scaling, it would be correct to interpret the `$stdres` as usual in non-weighted samples (i.e. standardized residuals significant if > 1.96)? – MDSF Mar 25 '21 at 16:29
  • Yes, roughly. That sort of thing is the point of scaling weights to sum to sample size – Thomas Lumley Mar 26 '21 at 06:06