1The Kern hook: counting burdened neighborhoods¶
California’s environmental-justice screening tool, CalEnviroScreen 4.0, scores every census tract in the state on cumulative pollution burden and population vulnerability, then reports each tract’s statewide percentile — the share of California tracts it scores at or above. By construction, exactly 25% of California tracts fall in the top quartile (percentile ). That is the statewide baseline: pick a California tract at random and there is a 1-in-4 chance it is “top-quartile burdened.”
Now ask the local question. Of the Kern County tracts with a reported score, what fraction land in that top statewide quartile?
ces <- read.csv("data/processed/kern_calenviroscreen.csv")
scored <- subset(ces, !is.na(ces_percentile)) # keep only tracts that have a score
n_kern <- nrow(scored) # how many scored Kern tracts
x_kern <- sum(scored$ces_percentile >= 75) # count in the statewide top quartile
phat <- x_kern / n_kern # sample proportion
c(n = n_kern, successes = x_kern, phat = round(phat, 4))Of the 147 scored Kern tracts, 73 are in the statewide top
quartile — a sample proportion of , very close to
half. (These values are computed above from
data/processed/kern_calenviroscreen.csv; the dataset’s codebook records 151
Kern tracts, 4 with no composite score.) The statewide baseline is 0.25. Kern’s
share is roughly double it.
But a sample proportion is not the whole story. Is convincingly different from the baseline 0.25, or could a county simply differ this much by chance? When the answer changes which neighborhoods get cleanup funding, you need more than a number — you need inference for a proportion. That is this whole chapter. By the end you will test exactly this claim and find the evidence is overwhelming: Kern really is more burdened than a typical California county.
2Learning objectives¶
After this chapter you will be able to:
(Apply) Construct a confidence interval for a single proportion and check the success/failure conditions.
(Apply) Conduct a one-sample -test for a proportion and interpret the result in context.
(Apply) Conduct a two-proportion -test and confidence interval, using the pooled standard error for the test.
(Analyze) Verify the independence and sample-size conditions for proportion inference and explain what goes wrong when they fail.
(Communicate) State a proportion conclusion — with its interval and its significance — for a non-technical audience.
Durable skills practiced: quantitative reasoning (inference for categorical outcomes) and quantitative communication (reporting a rate or a rate difference).
39.1 A proportion is a mean in disguise¶
3.1Intuition¶
A proportion is just the fraction of a group that has some trait: the share of tracts that are top-quartile burdened, the share of voters who say “yes,” the share of patients who recover. Code each unit as 1 for “has the trait” (a success) and 0 for “doesn’t” (a failure), and the proportion is simply the average of those 0/1 values. That is the key that unlocks everything: a proportion is a mean of 0/1 data, so all the sampling-distribution and confidence-interval ideas you already met for means carry straight over.
Because a proportion is a mean, the Central Limit Theorem from Chapter 6 applies. If your sample is large enough, the sampling distribution of — the proportion you’d get from repeated samples — is approximately normal, centered at the true population proportion , with a predictable spread. That normal shape is what lets us attach a -score, a -value, and an interval to a proportion.
3.2Formula¶
Let:
= the population proportion (the unknown truth we want to learn about).
= the sample proportion (read “p-hat”), our estimate of :
where = the number of successes in the sample and = the sample size (number of observations).
The standard error of — the typical distance between and across repeated samples — is
Here is the variance of a single 0/1 observation, and dividing by shrinks the spread as the sample grows (the familiar effect from Chapter 6).
This normal approximation is trustworthy only when two conditions hold:
Independence. Observations are independent — typically guaranteed by a random sample drawn from a population at least 10 times the sample size (so sampling without replacement barely changes the odds).
Success–failure. There are at least 10 successes and 10 failures expected, so the sampling distribution is close enough to normal. Which counts you check depends on whether you are testing or estimating (we make this precise in Section 4 and Section 5).
3.3R¶
Base R gives you one function for both single- and two-proportion inference,
prop.test(). For one proportion you pass the success count x, the sample size
n, and the hypothesized value p = ; adding correct = FALSE turns off
R’s continuity correction so the output lines up with the by-hand
normal-approximation () formula you just met. Here it is on a tiny made-up poll
of 540 “yes” out of 1000:
# 540 "yes" responses out of a 1000-person poll; test H0: p = 0.5.
prop.test(540, 1000, p = 0.5, correct = FALSE)Read the printout top to bottom, and you can read every proportion test in the chapter:
the title names the procedure (“1-sample proportions test without continuity correction”);
X-squared = 6.4is the test statistic.prop.testreports a chi-square value, and for a single proportion it is exactly the square of the you would compute by hand (), ondf = 1;p-value = 0.01141is the two-sided -value;the line
alternative hypothesis: true p is not equal to 0.5states (two-sided by default);the
95 percent confidence interval(here about 0.509 to 0.571) is R’s interval for — the Wilson score interval, a refined cousin of the Wald interval from Section 5;sample estimates: p = 0.54is .
Once you can read one prop.test printout, you can read them all — every example
below has the same shape.
49.2 Testing a single proportion¶
4.1Intuition¶
A hypothesis test for a proportion asks: if the population proportion were really some specific value , would a sample as extreme as ours be surprising? We assume the null hypothesis is true, build the sampling distribution that predicts, locate our on it, and ask how far out in the tail it sits. Far out (a small -value) means our data would be unlikely if were true — evidence against .
The subtle-but-important detail: when we test, we assume is true, so we compute the standard error using , not . This is the null standard error. (When we estimate with a confidence interval in Section 5, we have no hypothesized value to lean on, so we use instead. Same formula shape, different plug-in — keep them straight.)
4.2Formula¶
The one-proportion -statistic is
where:
= sample proportion = ,
= the hypothesized (null) proportion — the specific value claims,
= sample size.
The denominator is the null standard error . The -statistic counts how many null standard errors separate from .
The -value is the probability, under the standard normal curve, of a -score at least as extreme as ours, in the direction(s) named by the alternative hypothesis :
(two-sided): ,
(one-sided, greater): ,
(one-sided, less): .
Compare the -value to the significance level (often 0.05). If , reject ; otherwise fail to reject .
Test condition (success–failure under ): check and . Because the test assumes , the expected counts use .
4.3R¶
# Same poll: test H0: p = 0.5 against HA: p > 0.5 (is the "yes" share a majority?)
prop.test(540, 1000, p = 0.5, alternative = "greater", correct = FALSE)Setting alternative = "greater" makes the test one-sided, and the -value drops
to 0.005706 — half the two-sided value, because all of the probability now
sits in the upper tail. The object prop.test() returns also carries every number
as a named field ($statistic, $p.value, $conf.int, $estimate), so a script
or the Shiny app can read exact values with, say, prop.test(...)$p.value instead
of copying them off the screen.
59.3 Estimating a single proportion with a confidence interval¶
5.1Intuition¶
A confidence interval (CI) for a proportion gives a range of plausible values for the true , instead of a single test verdict. A 95% interval is built by a procedure that, across many samples, captures the true about 95% of the time. It answers “how big is it, and how sure are we?” rather than just “is it different from ?”
When estimating, we have no null value to assume, so we build the standard error from the data itself — the Wald standard error, using .
5.2Formula¶
A -level confidence interval for is
where:
= sample proportion,
= the critical value — the normal cutoff leaving in each tail (for 95%, ),
= the Wald standard error (note the , not ).
The piece after the ± is the margin of error, . A wider interval means more uncertainty; the interval narrows as grows and widens as the confidence level rises.
CI condition (success–failure from the data): check at least 10 observed successes () and 10 observed failures (). Here the counts use , because no is assumed.
5.3R¶
prop.test() always prints a confidence interval alongside the test. To change
the confidence level, set conf.level:
# A 90% CI for the "yes" share, from 540 of 1000.
prop.test(540, 1000, p = 0.5, conf.level = 0.90, correct = FALSE)The 90 percent confidence interval line now reads about 0.514 to 0.566 —
narrower than a 95% interval would be, because asking for less confidence buys a
tighter interval. R computes this as a Wilson score interval; the hand formula
below builds the closely related Wald interval .
69.4 Comparing two proportions¶
6.1Intuition¶
Often the real question is a difference: is the success rate in group 1 different from the rate in group 2? Are Hispanic-majority Kern tracts more likely to be top-quartile burdened than other Kern tracts? Now we have two sample proportions, and , and we care about .
The sampling distribution of that difference is again approximately normal (variances add when the two samples are independent), so the same machinery works — with one twist for the test. Under , both groups share one common proportion, so we estimate it by pooling all the successes from both groups. The test uses this pooled standard error; the confidence interval, which assumes no such equality, uses the unpooled standard error.
6.2Formula¶
Let group have successes in trials, so .
The pooled proportion combines both groups:
The two-proportion -statistic (testing ) is
where the denominator is the pooled standard error . The intuition: if is true, both groups estimate the same , so the best single estimate of it is the pooled one.
The confidence interval for uses the unpooled standard error (each group keeps its own ):
Conditions: independence within each group and between the two groups (separate random samples or a randomized experiment), plus the success–failure check in each group (at least 10 successes and 10 failures per group).
6.3R¶
For two proportions, prop.test() takes a vector of the two success counts and
a vector of the two sample sizes. (Naming the entries, as below, just gives the
data: line a tidy label.)
# Made-up trial: 45 of 100 recovered in group 1 vs 30 of 120 in group 2.
recovered <- c(group1 = 45, group2 = 30)
patients <- c(group1 = 100, group2 = 120)
prop.test(recovered, patients, correct = FALSE)The output now names two estimates — prop 1 = 0.45 and prop 2 = 0.25 —
and the 95 percent confidence interval (about 0.075 to 0.325) is for
their difference , built from the unpooled SE. The X-squared
statistic (9.71, p-value = 0.001832) is computed from the pooled proportion
behind the scenes, so both standard errors are at work in this single output even
though only the difference is printed.
Going deeper (optional) — why pool for the test, and what the p-value is not
Enrichment only; skip it if the basics are still settling.
Why pooling is the right move for the test. The null hypothesis says the two groups share one common population proportion. If that is true, then throwing away the group labels and estimating that single proportion from all the data — the pooled — uses every observation to estimate the one number the null cares about, giving the most precise null standard error. The confidence interval makes no such equality assumption (its whole job is to measure how unequal the groups are), so it must let each group keep its own — hence the unpooled SE. This is the proportion-world version of the same “test assumes , CI assumes nothing” split you saw for one proportion.
What the p-value is not. A small p-value here does not mean “there is a 1.3-in-a-hundred-million chance the null is true” (Example 3). The p-value is computed assuming the null is true — it is the chance of data this extreme under , never the chance that itself holds. Nor does a smaller p-value mean a bigger gap: with the large of survey data, even a few percentage points can be “significant.” The size of the gap lives in the confidence interval, not the p-value — which is exactly why this chapter always reports both.
The duality, briefly. Just as in Chapter 8, a two-sided two-proportion test at and the 95% CI for usually agree on whether 0 is plausible. For proportions they can occasionally disagree right at the boundary, because the test uses the pooled SE and the CI uses the unpooled SE — the one place these two tools quietly use different arithmetic (FAQ Q6).
79.5 Worked examples¶
Each example follows the course rhythm: intuition formula computation interpretation.
7.1Example 1 — Kern’s top-quartile share vs. the statewide baseline¶
(One-proportion test on the Kern CalEnviroScreen data.)
Intuition. By construction, 25% of California tracts are top-quartile burdened (percentile ). If Kern were a “typical” county, about a quarter of its tracts would land there. We saw in Section 1 that nearly half do. Is that gap real evidence of higher burden, or sampling noise? Test against , where is the true proportion of Kern tracts that are top-quartile burdened.
Formula. One-proportion with the null SE: , with .
Computation.
ces <- read.csv("data/processed/kern_calenviroscreen.csv")
scored <- subset(ces, !is.na(ces_percentile))
x <- sum(scored$ces_percentile >= 75)
n <- nrow(scored)
prop.test(x, n, p = 0.25, alternative = "greater", correct = FALSE)The success–failure check under uses and
, both well above 10, so the normal model is safe. From
of scored tracts, prop.test reports the sample estimate
and X-squared = 47.68 — which is exactly the square of the
by-hand statistic () — with a one-sided
p-value = 2.51e-12, astronomically small.
Interpretation. We reject . There is overwhelming evidence that more
than a quarter of Kern’s tracts are in the statewide top quartile of environmental
burden — far more than a “typical” county would have. In plain terms: Kern County
is disproportionately burdened, and the data say so loudly. (All values above are
computed from data/processed/kern_calenviroscreen.csv.)
7.2Example 2 — A confidence interval for that share¶
(One-proportion CI on the same data.)
Intuition. A test told us Kern’s share exceeds 0.25. Estimation asks how big the share actually is. Build a 95% confidence interval for .
Formula. with .
Computation.
prop.test(73, 147, p = 0.25, correct = FALSE)By hand, and
, giving the Wald interval
. R’s 95 percent confidence interval line
prints 0.4169 to 0.5765 — the Wilson score interval, close to but not
identical to the hand-computed Wald interval, because the two use slightly
different arithmetic (the note in Section 5). For an intro course either is
fine; just say which one you used.
Interpretation. We are 95% confident that between about 42% and 58% of Kern’s scored tracts are top-quartile burdened. The entire interval sits far above the statewide baseline of 25% — consistent with (and stronger than) the test in Example 1, because the whole plausible range excludes 0.25.
7.3Example 3 — Equity gap within Kern: two proportions¶
(Two-proportion test and CI on the Kern data.)
Intuition. Environmental-justice work asks who bears the burden. Split Kern’s
scored tracts into Hispanic-majority tracts (hispanic_pct ) and
not-majority tracts, and compare the proportion that are top-quartile burdened.
Test (no difference) against , where group 1 is
Hispanic-majority and group 2 is not.
Formula. Two-proportion with the pooled SE for the test; unpooled SE for the CI of .
Computation.
ces <- read.csv("data/processed/kern_calenviroscreen.csv")
d <- subset(ces, !is.na(ces_percentile) & !is.na(hispanic_pct))
# successes = top-quartile-burdened tracts; totals = all tracts, in each group
successes <- c(hispanic_majority = sum(d$ces_percentile >= 75 & d$hispanic_pct >= 50),
not_majority = sum(d$ces_percentile >= 75 & d$hispanic_pct < 50))
totals <- c(hispanic_majority = sum(d$hispanic_pct >= 50),
not_majority = sum(d$hispanic_pct < 50))
prop.test(successes, totals, correct = FALSE)Among 72 Hispanic-majority tracts, 53 are top-quartile burdened, so
prop.test prints prop 1 = 0.7361; among 75 not-majority tracts, 20
are, giving prop 2 = 0.2667. Their difference is
. The pooled proportion
drives the reported
X-squared = 32.38, which is again the square of the by-hand
(), with p-value = 1.27e-08.
Interpretation. We reject : Hispanic-majority Kern tracts are far more
likely to be top-quartile burdened than other Kern tracts. The 95 percent confidence interval for the difference prints as about — i.e.,
the burdened share is between roughly 33 and 61 percentage points higher in
Hispanic-majority tracts. (This interval is the unpooled one, exactly the
standard error a CI for a difference should use.) This is a real, large equity gap
in the data. (Note: CalEnviroScreen is observational, so this documents an
association, not a cause — see the caution in Section 13.)
7.4Example 4 — Reading conditions: a poll that fails the check¶
(A conditions cautionary example.)
Intuition. Conditions are not paperwork — they decide whether the normal model applies at all. Suppose a pilot survey finds only 6 successes in 40 trials and you want to test .
Formula. Test success–failure under : need and .
Computation. and — both exceed 10, so the test condition passes. But the CI condition uses the data: observed successes . The success–failure check for the interval fails.
prop.test(6, 40, p = 0.5, correct = FALSE)Interpretation. With only 6 observed successes, any hand-computed Wald interval
is unreliable — its normal approximation is shaky out in the tail. Helpfully,
prop.test never uses the fragile Wald formula: the interval it prints (about
0.071 to 0.291) is the Wilson score interval, which stays sensible when
a count is small, and is one of the recommended fixes here (an exact binomial or
Agresti–Coull interval are others). Even so, the failed success–failure check is
your early-warning signal. The lesson stands: always check the conditions before
you trust the number — the software will still hand you an interval, condition or
no condition.
89.6 Visualizing proportions¶
A bar chart of the two group proportions makes the equity gap from Example 3 immediate. We compute each group’s proportion, then plot.
ces <- read.csv("data/processed/kern_calenviroscreen.csv")
d <- subset(ces, !is.na(ces_percentile) & !is.na(hispanic_pct))
d$group <- ifelse(d$hispanic_pct >= 50, "Hispanic-majority", "Not-majority")
# tapply(condition, group, mean) = the fraction TRUE (top-quartile) within each group
props <- tapply(d$ces_percentile >= 75, d$group, mean)
plot_df <- data.frame(group = names(props), proportion = as.numeric(props))
ggplot(plot_df, aes(x = group, y = proportion, fill = group)) +
geom_col(width = 0.6) +
geom_text(aes(label = sprintf("%.0f%%", 100 * proportion)),
vjust = -0.4, size = 4.5) +
scale_fill_manual(values = okabe_ito, guide = "none") +
scale_y_continuous(limits = c(0, 0.85),
labels = function(x) sprintf("%.0f%%", 100 * x)) +
labs(
x = NULL,
y = "Top-quartile burdened",
title = "Kern environmental burden by tract demographics"
) +
theme_minimal(base_size = 12) +
theme(panel.grid.minor = element_blank(),
plot.title = element_text(face = "bold"))
Proportion of Kern County census tracts in the statewide top quartile of environmental burden, by tract demographic group. Hispanic-majority tracts (74%) are far more likely to be top-quartile burdened than not-majority tracts (27%), a gap of about 47 percentage points.
The figure uses the Okabe–Ito colorblind-safe palette (blue and orange), labels both bars with their percentages, and is described in full by its alt text so a screen-reader user gets the same takeaway: a roughly 47-point gap.
9Durable-skill callouts¶
10Try it¶
Shiny — Statistics Explorer, “One/Two-Sample Tests” module. Load
kern_calenviroscreen, build the top-quartile indicator, and run the one- and two-proportion tests with point-and-click controls. The live code panel shows the matchingprop.test()calls — copy them straight into your own script.Jupyter — Lab 9: Inference for Proportions (
labs/lab09-proportions.ipynb). A guided walkthrough recomputes Examples 1–3 from the raw CSV, then asks you to test a proportion of your own choosing (e.g., the share of tracts above the drinking-water-index median) and write a one-paragraph conclusion.
119.7 Practice problems¶
Work each problem fully before checking. Odd-numbered answers are in Appendix: Answers; full worked solutions are in the instructor key. Unless stated otherwise, use , two-sided alternatives, and 95% confidence. A calculator or R is allowed; keep full precision until the final step.
Conceptual.
Explain in one sentence why a proportion can be treated as the mean of a set of 0/1 values, and why that matters for inference.
State the two conditions required for the normal model to apply to a single proportion, and explain what each one protects against.
A test uses the standard error but a confidence interval uses . Explain why the two procedures use different standard errors.
For a two-proportion test, why do we pool the two samples into a single proportion, while for the interval we do not?
A colleague says “the -value is the probability that is true.” Give the correct interpretation of a -value in one sentence.
One proportion — tests.
A national poll of adults finds who favor a measure. Test vs. . Report , , the -value, and your decision.
In a random sample of 50 CSUB students, 38 report owning a laptop. Test whether a majority own a laptop ( vs. ). Report and the -value.
A manufacturer claims at most 10% of its chips are defective. In a sample of 200 chips, 18 are defective. Test vs. . What do you conclude?
A coin is flipped 40 times and lands heads 27 times. Test vs. at . Is there evidence the coin is biased toward heads?
For the chip data in Problem 8, check the success–failure condition under . Does the normal model apply?
One proportion — confidence intervals.
A survey of 400 commuters finds 120 use public transit. Construct a 95% confidence interval for the population proportion who use public transit.
Using the poll in Problem 6 (, ), construct and interpret a 95% confidence interval for .
Explain how the width of a 95% CI for a proportion changes if (a) the sample size quadruples, and (b) the confidence level rises to 99%.
A pilot study finds 6 successes in 40 trials. Explain why you should not report an ordinary Wald 95% CI here, and what condition fails.
A pollster wants a 95% CI for a proportion with margin of error at most 0.03, and has no prior guess for . Find the smallest sample size needed. (Hint: the worst case is .)
Two proportions.
A clinical trial reports 45 recoveries of 100 in the treatment group and 30 of 120 in the control group. Test vs. and report , the -value, and your decision.
For the trial in Problem 16, construct a 95% confidence interval for and interpret it.
In County A, 210 of 300 sampled residents support a bond; in County B, 180 of 300 do. Is support different between the counties? Test at .
For the counties in Problem 18, construct a 95% CI for the difference in support and state whether it is consistent with your test decision.
Explain why pooling is appropriate for the test in Problem 16 but not for the interval in Problem 17.
Kern CalEnviroScreen data (load it with
ces <- read.csv("data/processed/kern_calenviroscreen.csv")).
Define a tract as “high-PM2.5” if its
pm25exceeds 12 µg/m³ (the older EPA annual standard). Compute the sample proportion of Kern tracts that are high-PM2.5, and test whether a majority of tracts exceed 12 µg/m³ ( vs. ). Report , , and your decision.Construct a 95% confidence interval for the proportion of Kern tracts that are high-PM2.5 (as defined in Problem 21).
Define “high-PM2.5” instead as
pm25µg/m³ (the 2024 EPA standard). How does the sample proportion change, and what does that tell you about choosing a threshold?Re-run Example 3’s two-proportion comparison but define the demographic groups by the poverty indicator instead (poverty its median vs. below). Report the two sample proportions and the -value, and compare to the Hispanic-majority result.
In one or two sentences suitable for a county newsletter, report the result of Example 1 (Kern’s top-quartile share vs. the 25% baseline), including the estimate and a statement of significance, without using the word “-value.”
Reasoning and communication.
A report states “the two recovery rates were not significantly different ().” Does this prove the treatments are equally effective? Explain.
Two studies estimate the same proportion. Study A: , . Study B: , . Without computing, which has the narrower 95% CI, and why?
A one-sided test gives . What would the two-sided -value be for the same data, and which is appropriate if you had no prior direction in mind?
Explain why a statistically significant difference in proportions (very small -value) is not automatically a practically important difference. Give a plausible example.
Using the Kern equity gap from Example 3, write two sentences a city council member could read aloud: one stating the estimated gap with its interval, and one stating the appropriate causal caution.
129.8 Chapter summary¶
A proportion is the mean of 0/1 (success/failure) data, so the Central Limit Theorem makes the sampling distribution of approximately normal — the basis for all proportion inference.
One-proportion test: , using the null SE; compare the -value to . Condition: and .
One-proportion CI: , using the Wald SE. Condition: at least 10 observed successes and 10 failures.
Two-proportion test: pool the groups, , and use the pooled SE; the CI for uses the unpooled SE. Conditions: independence within and between groups, plus success–failure in each group.
In R,
prop.test()handles both one- and two-proportion inference: passx, n, p =for one proportion, or a vector of the two success counts and a vector of the two totals for a comparison. Addcorrect = FALSEto match the by-hand (/Wald) formulas; itsX-squaredstatistic is the square of that , and it prints a Wilson-score confidence interval.On the real Kern CalEnviroScreen data, ~50% of scored tracts are in the statewide top quartile of burden (vs. a 25% baseline, ), and Hispanic-majority tracts are ~47 percentage points more likely to be top-quartile burdened () — large, significant, and an association, not a proven cause.
139.9 FAQ¶
Q1. When do I use the null () standard error and when the sample () one? Use the null SE for a hypothesis test (you are assuming , so plug in ); use the Wald () SE for a confidence interval (no to assume). For two proportions, the test pools; the interval does not.
Q2. My test rejects but the difference looks tiny. What gives? With a large , even a small, practically meaningless difference can be statistically significant. Always pair the -value with the confidence interval so you can judge whether the size of the effect matters, not just whether it is nonzero (see Problem 29).
Q3. The success–failure condition fails — now what? The normal approximation is unreliable. Report the limitation and use an exact or adjusted method instead (for one proportion, an exact binomial test or the Agresti–Coull interval; these are introduced as tools you can reach for, not required formulas in this course).
Q4. Does the Kern equity result mean Hispanic demographics cause higher burden? No. CalEnviroScreen data are observational: tracts were not randomly assigned their demographics. The two-proportion test documents a strong association between tract demographics and environmental burden — a real, important pattern — but causation would require ruling out confounders (industrial siting history, housing policy, income). Report associations honestly and resist causal language (Chapter 1’s scope-of-inference lesson applies here).
Q5. One-sided or two-sided? Choose the alternative before seeing the data, based on the question. Use one-sided only when a direction is genuinely the only one of interest (“is it a majority?”); otherwise use two-sided. Never switch to one-sided after peeking to make a result “significant.”
Q6. Why does my 95% CI sometimes include values the test rejected, or vice versa? For two proportions, the test uses the pooled SE and the CI uses the unpooled SE, so they can occasionally disagree at the boundary. They usually agree; when they don’t, it is because they answer slightly different questions with slightly different standard errors. Trust the procedure that matches your goal (test for “is there a difference,” CI for “how big”).
Q7. What’s the smallest sample I can use? There is no single number, but the success–failure condition is the practical gate: you want at least 10 successes and 10 failures (per group, for two proportions). Below that, switch to exact methods.
14Resumen en español¶
Resumen del capítulo
En este capítulo aprendiste a hacer inferencia estadística sobre proporciones (proportions) — es decir, sobre la fracción de una población que tiene cierta característica. El ejemplo central viene de datos reales del Condado de Kern: de los 147 tramos censales con puntuación en CalEnviroScreen 4.0, aproximadamente la mitad (49.7%) se ubican en el cuartil superior (top quartile) de carga ambiental a nivel estatal, muy por encima del 25% que cabría esperar si Kern fuera un condado “típico” de California.
La idea clave es que una proporción es simplemente el promedio de datos de 0 y 1 — un “éxito” vale 1, un “fracaso” vale 0. Gracias a eso, el Teorema Central del Límite (Central Limit Theorem) garantiza que la distribución muestral (sampling distribution) de la proporción muestral es aproximadamente normal cuando la muestra es suficientemente grande. La condición práctica es que haya al menos 10 éxitos y 10 fracasos esperados.
Para probar una proporción frente a un valor hipotético , se calcula el estadístico :
El denominador es el error estándar nulo (null standard error), porque la prueba asume que es verdadera. Para el intervalo de confianza (confidence interval), en cambio, se usa el error estándar de Wald con en lugar de : .
Cuando comparas dos grupos — como los sectores de mayoría hispana versus los demás en Kern — usas una prueba de dos proporciones (two-proportion test). La novedad es la proporción agrupada (pooled proportion), , que se emplea solo en la prueba; el intervalo para la diferencia usa los errores estándar separados de cada grupo.
En R, la función prop.test() realiza la inferencia para una y dos proporciones; con correct = FALSE reproduce la fórmula de Wald calculada a mano, y su salida muestra el estadístico X-cuadrado (que es el cuadrado de ), el valor p y el intervalo de confianza (de tipo Wilson). El resultado de Kern es contundente: los sectores de mayoría hispana tienen una probabilidad aproximadamente 47 puntos porcentuales mayor de encontrarse en el cuartil de mayor carga ambiental — una asociación real y significativa, aunque no necesariamente causal, ya que los datos son observacionales.