Survey data: the Rao–Scott chi-square
Clusters and weights make a survey carry less information than its row count suggests. Rao–Scott corrects the chi-square test for the design you actually used.
What runs in CodeSplash
- STAT073Rao–Scott survey chi square test Runs in CodeSplash
- χ² test of independence Verified in Python and R
You will be able to
- Explain why clustered rows break Pearson's chi-square
- Apply the first-order correction using the design effect
- Give a survey's weights, clusters and strata to the test
When rows aren't independent
ReadPearson's treats every row as an independent draw. Surveys rarely work that way. A fieldworker visits a neighborhood and asks several people there, and neighbors tend to answer alike.
Those neighborhoods are primary sampling unitsPrimary sampling unitThe first unit drawn in a multistage sample (a school, a household, a village); rows in the same PSU tend to be alike.. Each extra person in a cluster adds less information than a fresh draw would.
The design effectDesign effectHow much the sampling design inflates a variance compared with a simple random sample of the same size. measures the loss: how much the design inflates a variance compared with a simple random sample of the same size. Ignore it, and your standard errors come out too small and your p-values too low.
Predict the change
PredictPredict first
A survey asks 360 people in 24 clusters about region and exercise. Ignoring the clusters gives = 18.08 on 6 df, p = .006. The mean design effect is 2.44.
What happens to the p-value once the design is respected?
Reveal
It gets much larger: p = .284. An association that looked clear is compatible with none at all.
Feel the inflation
ExploreThis explorable uses a t test on students in classrooms, but the mechanism is the same. Raise the intraclass correlation and watch the test that ignores clusters reject far more often than 5%, with no real effect present. Then compare adding people per cluster with adding clusters.
BExplorable · When observations come in clusters
What happens to a t test when students come in classrooms and you ignore it?
There is no true effect. How often does the naive t test reject?
Commit your prediction above to see the result
Make your prediction to see the result.
The correction
ReadThe Rao–ScottRao–Scott correctionAdjusts χ² for a complex sample (weights, clusters, strata) by dividing by the design effect, so p-values are not too small. first-order correction divides the statistic by the mean design effect:
Here that's on the same degrees of freedom. A rough reading: these respondents carry the information of about independent people.
The second-order version also allows for how much the design effects vary across the table. It refers an statistic to fractional degrees of freedom: F(3.49, 80.4) = 1.24, p = .302. It's the default here, and the form most software reports.
Weights change the table too
ReadWeights do more than remove information: they change the estimated table itself. So the corrected p-value isn't always the larger one.
| Survey | Ignoring the design | Rao–Scott |
|---|---|---|
| Weights only | p = .441 | p = .549 |
| Weights, clusters and strata | p = .602 | p = .342 |
In the second survey, the weighted shares differ from the raw ones, and the mean design effect is only 1.10, so there's little inflation to correct. Neither p-value is the conservative one by rule. Use the one that matches how the data were collected.
Know your design
ReflectThe correction is only as good as the design you describe. With fewer than about 20 clusters, the design degrees of freedom are small and the test becomes unreliable.
Think of the last survey you analyzed. Do you have its weights, its cluster identifiers and its strata? If you have only the weights, what would you ask the people who ran it?
Check your understanding
CheckpointCheck yourself
A Pearson statistic of 20 has a mean design effect of 2.5. What is the first-order Rao–Scott statistic?
Show the answer
Answer: 8
20 / 2.5 = 8, on the same degrees of freedom as the original test.
Check yourself
A clustered survey has 1,000 respondents and a design effect of 2.5. About how many independent respondents is it worth?
Show the answer
Answer: 400
1,000 / 2.5 = 400. Reporting the sample as 1,000 without that context overstates its precision.
Check yourself
Your data have 30 villages, with 20 households sampled in each, and no weights. What must you give the test?
Show the answer
Answer: b
The problem is dependence, and a large row count doesn't remove it. Equal weights change nothing. The cluster identifier is what lets the test see the dependence.
Check yourself
A study has 2,000 people, in only 8 clusters. What should worry you about a Rao–Scott test here?
Show the answer
Answer: a
Information about the design comes from the number of clusters, not the number of people. Eight clusters leave few design degrees of freedom.
Do it in CodeSplash
In the appThe test works on one row per respondent. Beside Rows and Columns, add Sampling weights, Clusters (PSUs) and Design strata, whichever your survey has. Any of them switches the card to Rao–Scott, which also reports the mean design effect. Rao–Scott correction chooses Second order or First order.
from scipy import stats
# SciPy and statsmodels have no Rao-Scott test. Given a mean design effect from
# survey software, this is the first-order correction by hand.
x2, deff, df = 18.08, 2.44, 6
print(x2 / deff, stats.chi2.sf(x2 / deff, df))library(survey) # install.packages("survey")
df <- read.csv("survey_design.csv")
design <- svydesign(ids = ~cluster, data = df)
svychisq(~region + exercise, design, statistic = "F") # second order
svychisq(~region + exercise, design, statistic = "Chisq") # first orderThe first-order output in R prints the uncorrected beside the corrected p-value.
Recap
Recap- Clustered rows carry less information than their count suggests, and Pearson's test doesn't know that.
- Rao–Scott divides by the design effect; the second-order form is the usual default.
- Give the test the real design. Weights alone don't deal with clusters, and few clusters limit any correction.
Concepts in this lesson