Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

1A Bakersfield neighborhood puzzle

Drive across Kern County and the air, the traffic, and the health of one neighborhood can look nothing like the next. California’s CalEnviroScreen tool tries to capture that by scoring every census tract — a small, neighborhood-sized Census area — on its combined pollution burden, then ranking each tract against every other tract in the state with a percentile from 0 (least burdened) to 100 (most burdened).

Here is a fact you can check yourself from the data shipped with this book. Of the 147 Kern County tracts that have a CalEnviroScreen score, 73 — very nearly half (49.7%) — fall in the statewide top quartile of burden (the worst 25% of tracts in all of California). If Kern were just an average slice of the state, we would expect only about 25% of its tracts up there, roughly 37 of them, not 73. (Source: kern_calenviroscreen codebook, data/processed/kern_calenviroscreen.csv; this chapter recomputes the count below.)

That gap — about 36 more high-burden tracts than “average” would predict — is the kind of thing this chapter teaches you to test. Is it a real departure from the “Kern is typical” story, or could a county just happen to land that way by chance? When your data are counts of categories rather than measured numbers like height or income, the tool for that question is the chi-square test. By the end of the chapter you will run exactly this test, get a chi-square statistic, and reach a defensible conclusion.

2Learning objectives

By the end of this chapter you will be able to:

  1. (Apply) Conduct a chi-square goodness-of-fit test and interpret the result in context.

  2. (Apply) Conduct a chi-square test of independence on a two-way (contingency) table.

  3. (Apply) Compute expected counts and verify the expected-count condition before trusting a chi-square result.

  4. (Analyze) Interpret which cells drive a significant result using standardized (Pearson) residuals.

  5. (Communicate) State a categorical-association conclusion with appropriate causal caution for a non-technical audience.

This chapter expands ISRS sections 3.3–3.4 (goodness of fit; independence in two-way tables). It assumes you have met frequency and contingency tables (Section 1 builds on Chapter 3) and the logic of hypothesis testing — null and alternative hypotheses, conditions, p-values, and the reject / fail-to-reject decision — from Chapter 8.

3Why a new test? The idea behind chi-square

You already know how to test a claim about a single proportion (Chapter 9) and about means (Chapter 10). But many real questions are about a whole table of counts at once:

Both questions have the same shape. You have a table of counts you actually observed. You can write down the table of counts you would expect if the boring “nothing special is going on” story (the null hypothesis) were true. The chi-square test measures, with a single number, how far the observed table is from the expected table — and then asks whether that distance is bigger than sampling noise could comfortably produce.

The mental picture: lay the observed table on top of the expected table. If they match cell-for-cell, there is nothing to report. The more the two tables disagree, the larger the chi-square statistic, and the more the data argue against the null story.

4Goodness-of-fit: do the counts match a claimed distribution?

4.1Intuition

You have one categorical variable with kk categories and a count in each. Some theory or claim says the categories should occur in certain proportions. The goodness-of-fit test asks: do the observed counts fit that claim well, or are some categories surprisingly over- or under-represented?

Think of the burden-quartile question. There are four categories (Q1–Q4). The “Kern is a typical slice of California” claim says each statewide quartile should catch about a quarter of Kern’s tracts. The test compares the four counts we see against the four counts that claim predicts.

4.2Formula

Let

The hypotheses are:

H0: the category proportions equal (p1,p2,,pk)HA: at least one proportion differs from its claimed value.H_0:\ \text{the category proportions equal } (p_1, p_2, \ldots, p_k) \qquad H_A:\ \text{at least one proportion differs from its claimed value.}

The chi-square statistic is

χ2  =  i=1k(OiEi)2Ei,\chi^2 \;=\; \sum_{i=1}^{k} \frac{(O_i - E_i)^2}{E_i},

where the sum runs over all kk categories. Each term measures how far one category’s observed count strayed from its expected count, scaled by how big the expected count is (a miss of 10 matters more when you only expected 5 than when you expected 500). Squaring makes every term positive and punishes big misses hard. The statistic is compared against a chi-square distribution with

df=k1df = k - 1

degrees of freedom (dfdf), where kk is the number of categories. A large χ2\chi^2 (far out in the right tail) gives a small p-value and argues against H0H_0.

4.3R

In mosaic the workflow is two steps you already know the shape of: build the count table with tally(), then hand it to xchisq.test(). The “x” in xchisq.test() stands for extra output — on top of the chi-square statistic and p-value, it prints each cell’s observed count, its (expected) count in parentheses, the [contribution to the chi-square statistic] in square brackets, and the ⟨Pearson residual⟩ in angle brackets. That grid is the “lay the observed table on the expected table” picture, made concrete. For goodness-of-fit you pass the one-way table of counts plus a vector p of hypothesized proportions.

# Load the real Kern environmental-justice data (one row per census tract).
ces <- read.csv("data/processed/kern_calenviroscreen.csv")

# Keep tracts that actually have a statewide burden percentile, then bin each
# tract into the statewide quartile its percentile falls in. cut() slices a
# numeric variable into labeled bins at the breakpoints you give.
scored <- subset(ces, !is.na(ces_percentile))
scored$quartile <- cut(
  scored$ces_percentile,
  breaks = c(0, 25, 50, 75, 100),
  labels = c("Q1 (0-25)", "Q2 (25-50)", "Q3 (50-75)", "Q4 (75-100)"),
  include.lowest = TRUE
)
observed <- tally(~ quartile, data = scored)
observed

The four observed counts are 11, 30, 33, and 73. Now run the test. Under “Kern is typical,” each statewide quartile should hold one-quarter of Kern’s tracts, so we hand xchisq.test() the null proportions p = rep(1/4, 4) (four equal quarters):

xchisq.test(observed, p = rep(1/4, 4))

Read the printout top to bottom. Each quartile shows its observed count on top, its expected count (36.75) in parentheses (147 tracts ÷ 4 quartiles), the [contribution to X-squared] it adds, and its ⟨Pearson residual⟩; Q1 lands far below expectation and Q4 far above. The headline line reports the totals, computed live from the data: X-squared = 55.422, df = 3, p-value = 5.581e-12 — that is χ2=55.42\chi^2 = 55.42 on df=3df = 3 with a p-value of about 5.6×10125.6\times10^{-12}, far below 0.0001. Because the p-value is far below our significance level α=0.05\alpha = 0.05 (the cutoff for “small enough to reject,” written with the Greek letter alpha, α\alpha, and carried over from Chapter 8), we reject H0H_0: Kern’s tracts are not spread evenly across the statewide burden quartiles.

gof_df <- data.frame(
  quartile = names(observed),
  observed = as.numeric(observed)
)
expected_each <- sum(observed) / length(observed)   # 147 / 4 = 36.75

ggplot(gof_df, aes(x = quartile, y = observed)) +
  geom_col(fill = ok_blue) +
  geom_hline(yintercept = expected_each, linetype = "dashed",
             color = ok_vermil, linewidth = 1) +
  annotate("text", x = 1, y = expected_each + 4,
           label = "expected if Kern were typical (36.75)",
           hjust = 0, color = ok_vermil, size = 3.6) +
  labs(x = "Statewide CalEnviroScreen burden quartile",
       y = "Number of Kern tracts") +
  theme(panel.grid.major.x = element_blank())
Bar chart of four burden quartiles for Kern census tracts. Observed counts rise sharply from 11 in Q1 to 30 in Q2, 33 in Q3, and 73 in Q4. A horizontal dashed reference line at 36.75 shows the equal-share expectation; Q4's bar is about double the line while Q1's bar is far below it, showing Kern tracts concentrate in the highest statewide burden quartile.

Observed vs. expected counts of Kern County census tracts in each statewide CalEnviroScreen burden quartile. Bars are observed counts; the dashed line marks the count expected (36.75) if Kern matched the statewide one-quarter-per-quartile pattern. Q4 towers far above the line and Q1 sits far below it, which is what makes the chi-square statistic large.

5Independence: are two categorical variables associated?

5.1Intuition

Now suppose each observation is cross-classified by two categorical variables, giving a two-way table (also called a contingency table). The test of independence asks: does knowing an observation’s row category tell you anything about its column category? If the two variables are independent, the column breakdown looks the same in every row. If they are associated, the breakdown shifts from row to row.

For the environmental-justice question, the rows might be a tract’s demographic makeup (Hispanic-majority or not) and the columns its burden level (top-quartile or not). Independence would mean high-burden tracts are just as common among Hispanic-majority neighborhoods as anywhere else. Association would mean the burden is not shared evenly.

5.2Formula

Lay out the data as a table with rr rows and cc columns. Let

If the row and column variables were independent, the expected count in a cell would be its row’s share times its column’s share times the total:

Eij  =  RiCjn.E_{ij} \;=\; \frac{R_i \, C_j}{n}.

That formula is the independence assumption written as arithmetic: the fraction of the whole table in row ii is Ri/nR_i/n, the fraction in column jj is Cj/nC_j/n, and under independence the fraction in their intersection is the product (Ri/n)(Cj/n)(R_i/n)(C_j/n), so its expected count is n(Ri/n)(Cj/n)=RiCj/nn \cdot (R_i/n)(C_j/n) = R_iC_j/n.

The hypotheses are:

H0: the row variable and the column variable are independentHA: the two variables are associated.H_0:\ \text{the row variable and the column variable are independent} \qquad H_A:\ \text{the two variables are associated.}

The statistic is the same sum as before, now over every cell of the table:

χ2  =  i=1rj=1c(OijEij)2Eij,\chi^2 \;=\; \sum_{i=1}^{r}\sum_{j=1}^{c} \frac{(O_{ij} - E_{ij})^2}{E_{ij}},

compared against a chi-square distribution with

df=(r1)(c1)df = (r - 1)(c - 1)

degrees of freedom, where rr is the number of rows and cc the number of columns. The same expected-count condition applies: every EijE_{ij} should be at least 5.

5.3R

Build the two-way table with tally(y ~ x, data = D) and pass it to xchisq.test():

# Classify each scored tract two ways: by demographic makeup and by burden.
# ifelse(condition, A, B) labels a row "A" when the condition is true, else "B".
scored$demographic <- ifelse(scored$hispanic_pct >= 50,
                             "Hispanic-majority", "Not Hispanic-majority")
scored$burden      <- ifelse(scored$ces_percentile >= 75,
                             "High burden", "Lower burden")

# tally(y ~ x) builds the two-way count table -- burden broken down by demographic.
burden_table <- tally(burden ~ demographic, data = scored)
burden_table
# correct = FALSE turns off R's automatic Yates continuity correction for 2x2
# tables, giving the textbook Pearson chi-square -- the version for which
# chi-square = z-squared against Chapter 9's two-proportion z-test.
xchisq.test(burden_table, correct = FALSE)

Live from the data, this gives χ2=32.38\chi^2 = 32.38 on df=(21)(21)=1df = (2-1)(2-1) = 1, with a p-value of about 1.3×1081.3\times10^{-8} — far below 0.05. We reject independence: in these Kern tracts, demographic makeup and pollution burden are associated. The xchisq.test() grid already lays the observed counts over their expected counts and prints the residuals; section Section 6 reads those residuals to show how the two variables are associated.

6Reading the table after a significant result: standardized residuals

A significant chi-square tells you the table departs from the null — but not which cells are responsible. Standardized (Pearson) residuals pinpoint them. For each cell,

rij  =  OijEijEij,r_{ij} \;=\; \frac{O_{ij} - E_{ij}}{\sqrt{E_{ij}}},

the gap between observed and expected, scaled by the square root of the expected count. A residual is just a signed, standardized version of the per-cell contribution to χ2\chi^2. As a rule of thumb, a residual larger than about +2 flags a cell with more observations than independence predicts, and a residual below about -2 flags a cell with fewer. Cells near 0 behave as the null expected.

# The test already displayed the residuals; you can also pull the expected
# table and the standardized residuals straight out of the saved test object.
ind <- xchisq.test(burden_table, correct = FALSE)
round(ind$expected, 2)     # expected counts E = (row total)(column total)/n
round(ind$residuals, 2)    # standardized (Pearson) residuals (O - E)/sqrt(E)

The residuals are about +2.88 for Hispanic-majority/High-burden, -2.86 for Hispanic-majority/Lower-burden, -2.83 for Not-Hispanic-majority/ High-burden, and +2.81 for Not-Hispanic-majority/Lower-burden. Read in plain language: Hispanic-majority tracts are high-burden far more often than independence would predict, and other tracts are high-burden far less often. The residuals tell you the direction of the association the chi-square test detected.

7Worked examples

Each example runs the full arc: intuition \rightarrow formula \rightarrow computation \rightarrow interpretation. At least one uses the chapter’s Kern dataset.

7.1Worked Example 1 — Goodness-of-fit on Kern’s burden quartiles (Kern dataset)

Question. Are Kern County’s census tracts spread evenly across the four statewide CalEnviroScreen burden quartiles, or do they concentrate at one end?

Intuition. “Spread evenly” is the boring null: a quarter of Kern’s tracts in each statewide quartile. We compare what we see against that even split.

Formula. Goodness-of-fit with k=4k = 4 categories, null proportions pi=1/4p_i = 1/4, expected counts Ei=npiE_i = n\,p_i, statistic χ2=(OiEi)2/Ei\chi^2 = \sum (O_i - E_i)^2/E_i, and df=k1=3df = k - 1 = 3.

Computation. Among n=147n = 147 scored tracts the observed counts are O=(11,30,33,73)O = (11, 30, 33, 73) for Q1–Q4. Each expected count is Ei=147×14=36.75E_i = 147 \times \tfrac14 = 36.75. The per-category terms are

(1136.75)236.75=18.04,(3036.75)236.75=1.24,(3336.75)236.75=0.38,(7336.75)236.75=35.76,\frac{(11-36.75)^2}{36.75}=18.04,\quad \frac{(30-36.75)^2}{36.75}=1.24,\quad \frac{(33-36.75)^2}{36.75}=0.38,\quad \frac{(73-36.75)^2}{36.75}=35.76,

which sum to χ2=55.42\chi^2 = 55.42 on df=3df = 3, giving p5.6×1012p \approx 5.6\times10^{-12}. (Every expected count is 36.75, comfortably above 5, so the condition holds.)

ces <- read.csv("data/processed/kern_calenviroscreen.csv")
scored <- subset(ces, !is.na(ces_percentile))
scored$q <- cut(scored$ces_percentile, breaks = c(0, 25, 50, 75, 100),
                labels = c("Q1", "Q2", "Q3", "Q4"), include.lowest = TRUE)
xchisq.test(tally(~ q, data = scored), p = rep(1/4, 4))

Interpretation. We reject the even-split null. Kern’s tracts pile up in the highest statewide burden quartile (73 observed where 37 were expected) and are scarce in the lowest (11 where 37 were expected). Kern is not a typical slice of California for pollution burden — it is shifted decisively toward the high-burden end. (This does not, by itself, explain why.)

7.2Worked Example 2 — Independence of demographics and burden (Kern dataset)

Question. In Kern’s tracts, is being a high-burden tract associated with being a Hispanic-majority tract?

Intuition. If burden were shared evenly, the share of high-burden tracts would be the same among Hispanic-majority and other neighborhoods. We test whether the two classifications move together.

Formula. Independence on a 2×22\times2 table: Eij=RiCj/nE_{ij} = R_iC_j/n, χ2=(OijEij)2/Eij\chi^2 = \sum (O_{ij}-E_{ij})^2/E_{ij}, df=(21)(21)=1df = (2-1)(2-1) = 1.

Computation. The observed table (rows = demographic, columns = burden) is

High burdenLower burdenRow total
Hispanic-majority531972
Not Hispanic-majority205575
Column total7374147

The expected count for the top-left cell is E11=(72)(73)/147=35.76E_{11} = (72)(73)/147 = 35.76; the others are 36.24, 37.24, 37.76 — all above 5. Summing (OE)2/E(O-E)^2/E over the four cells gives χ2=32.38\chi^2 = 32.38, df=1df = 1, p1.3×108p \approx 1.3\times10^{-8}.

scored$demographic <- ifelse(scored$hispanic_pct >= 50,
                             "Hispanic-majority", "Not Hispanic-majority")
scored$burden <- ifelse(scored$ces_percentile >= 75,
                        "High burden", "Lower burden")
xchisq.test(tally(burden ~ demographic, data = scored), correct = FALSE)

xchisq.test() reports the strength of the association only indirectly (through the statistic), so compute the Cramér’s V effect size straight from the formula in Section 9:

tab   <- tally(burden ~ demographic, data = scored)
chi2  <- chisq.test(tab, correct = FALSE)$statistic   # the bare statistic, no printout
# V = sqrt( chi^2 / (n * min(rows-1, cols-1)) )
sqrt(as.numeric(chi2) / (sum(tab) * min(dim(tab) - 1)))

Interpretation. We reject independence: demographic makeup and pollution burden are associated in these Kern tracts. To describe how strong that association is, we use Cramér’s V — an effect size that rescales the chi-square statistic onto a 0-to-1 scale, where 0 means no association and 1 means a perfect one (its formula is in Section 9 and Problem 28). Here Cramér’s V is about 0.47, which signals a moderately strong association — not a faint one. The residuals in Section 6 show the association runs in the direction of Hispanic-majority tracts carrying more burden. Because these are observational data, we report the association, not a cause.

7.3Worked Example 3 — A three-row independence test: PM2.5 and poverty (Kern dataset)

Question. Across Kern’s tracts, is a tract’s PM2.5 air-pollution level (low / medium / high) associated with whether it has high poverty?

Intuition. Splitting PM2.5 into three levels and poverty into two gives a 3×23\times2 table. If pollution and poverty were unrelated, the high-poverty share would be roughly constant across the three pollution levels.

Formula. Same independence machinery, now r=3r = 3, c=2c = 2, so df=(31)(21)=2df = (3-1)(2-1) = 2.

Computation. Cutting PM2.5 at its tertiles and poverty at its median gives:

High povertyLow povertyRow total
Low PM2.5252449
Med PM2.5143549
High PM2.5351449
Column total7473147

Every expected count is about 24.324.7 (all above 5). The statistic is χ2=18.01\chi^2 = 18.01 on df=2df = 2, p1.2×104p \approx 1.2\times10^{-4}.

keep <- subset(ces, !is.na(pm25) & !is.na(poverty))
keep$pm_level <- cut(keep$pm25,
                     breaks = quantile(keep$pm25, c(0, 1/3, 2/3, 1)),
                     labels = c("Low", "Med", "High"), include.lowest = TRUE)
keep$pov_level <- ifelse(keep$poverty >= median(keep$poverty),
                         "High poverty", "Low poverty")
xchisq.test(tally(pov_level ~ pm_level, data = keep))

Interpretation. We reject independence: PM2.5 level and poverty are associated. But notice the pattern is not a tidy “more pollution \rightarrow more poverty” ladder — the highest poverty share sits in the high PM2.5 row, yet the lowest poverty share sits in the medium PM2.5 row, not the low one. A chi-square test detects association but says nothing about its shape; you must read the table (and residuals) to describe it, and resist inventing a trend the test never claimed.

7.4Worked Example 4 — A non-significant table: crop type and year-over-year growth (Kern context)

Question. Using the simulated Kern crop panel, is a commodity’s type (perennial tree/vine crops vs. annual field/vegetable crops) associated with whether its production grew from one year to the next?

Intuition. Each (commodity, year) record either grew over the prior year or did not. We cross “perennial vs. annual” with “grew vs. did not grow.” If type and growth were unrelated, perennials and annuals would grow in the same proportion of years.

Formula. Independence on a 2×22\times2 table, df=1df = 1.

Computation. Across the 64 year-over-year records the table is:

GrewDid not growRow total
Annual8816
Perennial262248
Column total343064

The smallest expected count is 7.5 (still above 5). The statistic is only χ2=0.08\chi^2 = 0.08 on df=1df = 1, p0.77p \approx 0.77.

crops <- read.csv("data/processed/kern_crops_sim.csv")
crops <- crops[order(crops$commodity, crops$year), ]   # sort by crop, then year

# For each commodity, "prev" = that crop's production the PREVIOUS year. ave()
# runs the little function separately within each commodity; c(NA, head(x, -1))
# shifts each crop's values down one row (the first year has no prior year, so
# it becomes NA).
crops$prev <- ave(crops$production, crops$commodity,
                  FUN = function(x) c(NA, head(x, -1)))

g <- subset(crops, !is.na(prev))                       # drop each crop's first year
g$grew <- ifelse(g$production > g$prev, "Grew", "Did not grow")
g$type <- ifelse(g$category %in% c("NUTS", "FRUIT", "CITRUS"),
                 "Perennial", "Annual")
xchisq.test(tally(grew ~ type, data = g), correct = FALSE)

Interpretation. We fail to reject independence (p0.77p \approx 0.77): in this simulated panel there is no evidence that crop type is associated with whether production grew. This is the honest, common outcome — most tables you test will not show a significant association, and “no evidence of association” is a real, reportable finding, not a failure. Notice too that failing to reject is not proof the variables are independent; it only means the data did not give us enough reason to doubt it.

8Try it yourself

9Chapter summary

10Frequently asked questions

1. When do I use goodness-of-fit versus a test of independence? Count your categorical variables. One variable compared to a claimed set of proportions \rightarrow goodness-of-fit. Two variables cross-classified in a table, asking whether they are associated \rightarrow test of independence.

2. The condition is about expected counts, but my table has a cell with 0 observed. Is that a problem? Not necessarily. The rule is about expected counts, not observed ones. A cell can show 0 observed and still satisfy the condition if its expected count is 5 or more. Only small expected counts break the test.

3. What do I do if some expected counts are below 5? Combine sparse categories into a larger, meaningful category, collect more data, or switch to an exact method (Fisher’s exact test for a 2×22\times2 table). Do not report the chi-square p-value as-is when the condition fails.

4. Why is the chi-square test almost always one-sided (right tail)? The statistic measures distance between observed and expected; any departure from the null — in any direction — makes it bigger. So evidence against H0H_0 always lives in the right tail, and the p-value is the area to the right of your statistic. You never split this into two tails.

5. Does a significant chi-square tell me which group is higher? No. By itself it only says “the table departs from the null.” To say where and in which direction, inspect the standardized residuals (Section 6) or compare conditional proportions across rows.

6. My p-value is tiny — does that mean a strong, important effect? Not on its own. A tiny p-value with a huge sample can accompany a weak association. Always report an effect size such as Cramér’s V alongside the p-value to describe the strength, not just the presence, of the effect.

7. Can I run chi-square on percentages or averages instead of counts? No. Chi-square needs raw counts of observations in each cell. Percentages and means have lost the sample-size information the test depends on. Convert back to counts first.

8. How is this different from the two-proportion test in Chapter 9? For a 2×22\times2 table comparing two proportions, the chi-square test of independence and the two-proportion z-test give the same p-value (χ2=z2\chi^2 = z^2). Chi-square is the natural generalization once you have more than two categories in either direction.

11Glossary

The glossary terms introduced in this chapter (chi-square statistic, expected count, goodness-of-fit test, test of independence, contingency table, observed count, standardized residual, Cramér’s V, degrees of freedom for chi-square) are collected in the book’s Glossary.

12Practice problems

Work these by hand where a formula is asked, and confirm with xchisq.test() (build the count table with tally() first). Odd-numbered problems have short answers in the answer appendix; full worked solutions are in the instructor key. Use α=0.05\alpha = 0.05 unless told otherwise. Several problems use the kern_calenviroscreen and kern_crops_sim datasets shipped with this book.

  1. A goodness-of-fit test has k=6k = 6 categories. How many degrees of freedom does it use?

  2. A test of independence is run on a table with 4 rows and 3 columns. State the degrees of freedom.

  3. In a goodness-of-fit test, one category has observed count O=12O = 12 and expected count E=20E = 20. Compute that category’s contribution (OE)2/E(O-E)^2/E to the chi-square statistic. Round to two decimals.

  4. A two-way table has row total Ri=60R_i = 60, column total Cj=45C_j = 45, and grand total n=150n = 150. Compute the expected count EijE_{ij} for that cell.

  5. A four-category goodness-of-fit test on n=200n = 200 observations uses the null proportions (0.4,0.3,0.2,0.1)(0.4, 0.3, 0.2, 0.1). List the four expected counts and confirm they sum to 200.

  6. Explain in one or two sentences why the chi-square test puts all of its “evidence against H0H_0” in the right tail of the distribution.

  7. A chi-square test of independence gives χ2=9.5\chi^2 = 9.5 on df=4df = 4. Without R, is the result significant at α=0.05\alpha = 0.05? (The critical value for df=4df = 4 is about 9.49.) State your decision.

  8. A cell in an independence test has observed count Oij=30O_{ij} = 30 and expected count Eij=18E_{ij} = 18. Compute its standardized residual (OijEij)/Eij(O_{ij}-E_{ij})/\sqrt{E_{ij}} and say whether the cell has more or fewer observations than independence predicts.

  9. A goodness-of-fit test on k=3k = 3 categories with n=30n = 30 has all null proportions equal. One expected count works out to 10. Does the table satisfy the expected-count condition? Explain.

  10. State, in your own words, the null and alternative hypotheses for a chi-square test of independence between a tract’s demographic majority and its burden level.

  11. Using kern_calenviroscreen, bin tracts into the four statewide burden quartiles (as in Section 7.1) and report the four observed counts. Then run the goodness-of-fit test against equal proportions and state χ2\chi^2, dfdf, and your decision.

  12. Two researchers test the same 2×22\times2 table. One runs a two-proportion z-test and gets z=3.2z = 3.2. What chi-square statistic should the other get from the test of independence, and why?

  13. In Section 7.2 the largest standardized residual is about +2.88 for the Hispanic-majority / high-burden cell. Interpret what that residual means in one plain-language sentence.

  14. A goodness-of-fit test produces χ2=2.1\chi^2 = 2.1 on df=3df = 3 (p0.55p \approx 0.55). Write a one-sentence conclusion in context for a claim that “the four categories occur equally often.”

  15. Using kern_crops_sim, build the two-way table of crop category (the five-level variable) by year-era (year <= 2019 vs. year >= 2020). Before running anything, explain why the expected-count condition is worth checking for this particular table.

  16. A chi-square test of independence is significant with a large sample, but Cramér’s V is only 0.06. Explain to a non-statistician what this combination means.

  17. Using kern_calenviroscreen, reproduce the demographics-by-burden independence test from Section 7.2 and report χ2\chi^2, dfdf, the p-value, and Cramér’s V. State your decision at α=0.05\alpha = 0.05.

  18. A student writes: “The chi-square test proved that Hispanic-majority neighborhoods cause higher pollution.” Identify the error and rewrite the sentence so it is defensible.

  19. A goodness-of-fit test of a fair six-sided die uses 60 rolls. State the expected count per face and the degrees of freedom. If the observed counts were (8,9,10,11,10,12)(8, 9, 10, 11, 10, 12), do you expect a large or small χ2\chi^2? Why?

  20. For a 2×32\times3 table of independence, you compute all six expected counts and the smallest is 3.2. State what you should do before reporting a chi-square p-value, and name one alternative method.

  21. Using kern_calenviroscreen, split tracts into “high PM2.5” vs. “low PM2.5” at the median pm25, and “high education-gap” vs. “low” at the median education (% adults without a high-school diploma). Run the test of independence and report χ2\chi^2, dfdf, and your decision.

  22. Explain the difference between an observed count and an expected count in a chi-square test, and which one you compute from the null hypothesis.

  23. A goodness-of-fit test on four categories has observed counts (40,30,20,10)(40, 30, 20, 10) and null proportions all equal. Compute the expected counts, the chi-square statistic, and state dfdf.

  24. You reject H0H_0 in a 4×44\times4 test of independence. Describe the next step you would take to explain which cells drive the result, and what cutoff you would use to flag a cell.

  25. A colleague reports a chi-square test run on column percentages that each row sums to 100%. Explain why the resulting p-value cannot be trusted and what they must supply instead.

  26. Using kern_crops_sim, reproduce the crop-type-by-growth independence test from Section 7.4. Report χ2\chi^2, dfdf, and the p-value, and write a one-sentence conclusion. Why is “fail to reject” not the same as “the variables are independent”?

  27. The chi-square distribution has only positive values and a long right tail. Explain why it cannot be negative, referring to the formula for χ2\chi^2.

  28. A two-way table has χ2=40\chi^2 = 40, n=500n = 500, with 3 rows and 4 columns. Compute Cramér’s V using V=χ2/(nmin(r1,c1))V = \sqrt{\chi^2 / (n \cdot \min(r-1, c-1))} and comment on the strength of the association.

  29. Write null and alternative hypotheses, in context, for a goodness-of-fit test of whether Kern’s tracts are evenly split across the four statewide burden quartiles.

  30. A report claims “there was no association (p = 0.42), proving the two variables are independent.” Rewrite the conclusion so it correctly reflects what a non-significant chi-square test does and does not establish.

13Resumen en español