Skip to contents

The cell entries are estimated population counts, so Pearson's statistic computed on them is wrong twice: it is on the population scale, and it ignores the variance the weights inflate. Rao and Scott's first-order correction evaluates Pearson's statistic on the weighted proportions and multiplies by the effective sample size neff = (sum w)^2 / sum w^2 in place of n. With equal weights neff = n and the statistic is exactly the uncorrected chisq.test statistic.

Usage

Svytbl(x, y, weights = NULL)

Arguments

x

Row category labels.

y

Column category labels, same length.

weights

Optional design weights; equal weights if NULL.

Value

List with estimate, statistic_naive, df, p_value, counts (row-major), prop, rows, cols, nrow, ncol, neff, deff, n, method.

Details

Formula: X2 = neff sum_ij (p_ij - p_i. p_.j)^2 / (p_i. p_.j), referred to chi-square on (r-1)(c-1) degrees of freedom.

References

Rao, J. N. K. and Scott, A. J. (1984). On chi-squared tests for multiway contingency tables with cell proportions estimated from survey data. The Annals of Statistics 12(1):46-60. doi:10.1214/aos/1176346391

Examples

Svytbl(c(0, 0, 0, 0, 1, 1, 1, 1), c(0, 0, 1, 1, 0, 1, 1, 1))
#> $estimate
#> [1] 0.5333333
#> 
#> $statistic_naive
#> [1] 0.5333333
#> 
#> $df
#> [1] 1
#> 
#> $p_value
#> [1] 0.4652088
#> 
#> $counts
#> [1] 2 2 1 3
#> 
#> $prop
#> [1] 0.250 0.250 0.125 0.375
#> 
#> $rows
#> [1] "0" "1"
#> 
#> $cols
#> [1] "0" "1"
#> 
#> $nrow
#> [1] 2
#> 
#> $ncol
#> [1] 2
#> 
#> $neff
#> [1] 8
#> 
#> $deff
#> [1] 1
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "Rao-Scott first-order corrected Pearson chi-square [Rao & Scott 1984]"
#>