1/27
Looks like no tags are added yet.
Null vs alternative hypothesis (Which statement becomes H0, and which H1?)
H0 is the statement that would be most costly to wrongly reject, so it is the current belief or status quo, and the equality sign (=, ≤, ≥) always lives in H0 (e.g. 'no effect', 'mean = mu0'); H1 is the claim we need evidence for. The sign of H1 (>,
Type I error (What is it, and what is its probability?)
A Type I error means rejecting H0 although H0 is true (a false alarm). Its probability is the significance level alpha, which we choose before looking at the data (e.g. 0.05).
Type II error (What is it, and what is its probability?)
A Type II error means not rejecting H0 although H1 is true (a missed effect). Its probability is beta; it gets smaller when n grows, when the true effect is bigger, or when alpha is larger.
Power (How is it defined, and what raises it?)
Power = 1 − beta, the probability of rejecting H0 when H1 is true. It rises with a larger sample size, a larger true effect, a larger alpha and a smaller standard deviation.
Test statistic (What does it measure?)
A test statistic measures how many standard errors the sample estimate lies away from the value assumed under H0: (estimate − null value) / SE. The further from 0, the stronger the evidence against H0.
p-value (Correct definition)
The p-value is the probability, assuming H0 is true, of getting a test statistic at least as extreme as the one observed. We reject H0 when p-value < alpha.
p-value trap (Is the p-value the probability that H0 is true?)
No. The p-value is computed assuming H0 is true, so it cannot be the probability that H0 is true. It is also not the probability of making a mistake with this decision.
'Accept H0' trap (What is the correct wording when p ≥ alpha?)
We say 'do not reject H0' or 'there is not enough evidence for H1'. A test never proves H0; failing to reject can simply mean the sample was too small (low power).
One-sided vs two-sided tests (How are p-values and the rejection region different?)
In a one-sided test all of alpha sits in one tail and the p-value is the area in that tail only; in a two-sided test the p-value is 2 × the smaller tail area and alpha/2 sits in each tail. For the same data the two-sided p-value is twice the one-sided p-value (when the sign matches H1).
Test SE vs CI SE for proportions (Why do they differ, and which one is bigger?)
The test assumes H0 is true, so it plugs in p0; the CI has no assumed value, so it plugs in p̂. Whichever of p0 and p̂ is closer to 0.5 gives the larger standard error. statsmodels proportions_ztest uses p̂ unless you pass prop_var=p0.
Duality of confidence interval and test (How can a two-sided CI decide a test?)
A two-sided test at level alpha rejects H0: mu = mu0 exactly when mu0 lies outside the (1 − alpha) confidence interval. For a proportion this holds only approximately, because the test SE (p0) and the CI SE (p̂) differ.
Dependent vs independent samples (What decides it?)
The design decides, not the correlation: dependent (paired) samples are ONE group measured on TWO variables (or conditions), e.g. the same students before and after; independent samples are TWO different groups measured on ONE variable. Two independent groups can still be correlated by chance; that does not make them paired.
Paired test step 1 (How do we build the data and what is the hypothesis?)
Form the difference d = x1 − x2 for each pair and test H0: mu_d = 0 with a one-sample t-test on d (df = n − 1), so a paired test is one-sample inference on d. The order of subtraction fixes the sign: if H1 says 'after is larger than before', d must be after − before.
Paired data with missing values (What do you do with incomplete pairs, and what is n?)
Drop every pair where either value is missing (dropna on the pair), and never fill the gap with 0, because a fake 0 distorts the mean difference. n is the number of COMPLETE pairs, and df = n − 1 uses that n.
Paired data in Python (Which coding traps cause wrong answers?)
Do not overwrite a column name when creating d (the original column is lost), and do not compute d with NaNs left in without dropna, because a NaN spreads into the mean or the count. Check n after building d: it must equal the number of complete pairs.
Independent means, known variances (Which test and statistic?)
If both population variances are known, use a z-test: z = ((x̄1 − x̄2) − 0) / √(σ1²/n1 + σ2²/n2), with no t distribution. In Python this needs your own small function, because the library t-tests assume unknown variances. This case is mostly theoretical.
Independent means, unknown variances (Which distribution is used?)
If the variances are unknown (the normal case), use the t distribution (not z); the course workflow does not switch to z for large samples. First decide between pooled and Welch with an equal-variance test.
Equal-variance test (What do we compare, and what does the p-value mean for the choice?)
Run a test of H0: σ1² = σ2² and compare its p-value with 5 %: if p > 0.05 we do not reject equal variances and use the pooled t-test; if p < 0.05 we reject it and use Welch. This choice comes before the test on the means.
Pooled t-test (Formula, df, assumption)
The pooled t-test assumes equal variances: sp² = ((n1 − 1)s1² + (n2 − 1)s2²)/(n1 + n2 − 2), SE = sp·√(1/n1 + 1/n2), and df = n1 + n2 − 2. It is used when the equal-variance test does not reject.
Welch t-test (Formula, df, rounding)
Welch's t-test uses SE = √(s1²/n1 + s2²/n2) and an adjusted ('new') df from the Welch-Satterthwaite formula, which is smaller than n1 + n2 − 2 and not an integer. Round the df UP when you need a table or critical value. It is used when the equal-variance test rejects.
statsmodels default for two means (What is usevar by default?)
In statsmodels (ttest_ind / CompareMeans) usevar='pooled' is the default, so you get the POOLED test unless you pass usevar='unequal' for Welch. scipy's ttest_ind similarly assumes equal variances unless equal_var=False. Always set the option on purpose.
Sign of the difference (Why does the order of subtraction matter?)
The statistic and the CI for mu1 − mu2 flip sign if you subtract in the other order, and 'greater/less' in H1 must match your order. Write H1 in terms of the same difference you compute, e.g. mu_A − mu_B > 0 when A is claimed to be larger.
Confidence interval for a difference of means (How do we read it?)
If both bounds are > 0, mean 1 is significantly larger than mean 2; if both are < 0, mean 1 is significantly smaller; if the interval contains 0, we cannot conclude a difference. For a two-sided test at the matching level this gives the same decision as the p-value.
Test vs CI for a difference (What does each plug in for the difference?)
The test puts the H0 value in the statistic: t = ((x̄1 − x̄2) − 0)/SE, so it measures distance from 0. The CI does not use H0: it is (x̄1 − x̄2) ± t*·SE, centred on the observed difference.
Two proportions, conditions (Which checks are needed?)
All four counts must be at least 10: n1·p, n1·(1 − p), n2·p, n2·(1 − p) (with the pooled p̄ for the test, and p̂1, p̂2 for the CI). If one fails, the normal approximation is not valid and the test result cannot be trusted.
Two proportions, test statistic (Pooled or separate p?)
The TEST pools: p̄ = (x1 + x2)/(n1 + n2) and z = (p̂1 − p̂2)/√(p̄(1 − p̄)(1/n1 + 1/n2)), because H0: p1 = p2 says both groups share one proportion. The CI uses the separate p̂1 and p̂2 in the SE (be very careful with the wording of the question).
Two proportions, worked example from 19.11. (n = 25 each, x = 15 and 10)
p̂1 = 0.60, p̂2 = 0.40, difference 0.20, pooled p̄ = 25/50 = 0.50, so SE0 = √(0.5·0.5·(1/25 + 1/25)) = 0.1414 and z = 1.414, two-sided p ≈ 0.157: do not reject H0 at 5 %. The CI uses separate p̂ in the SE (√(0.6·0.4/25 + 0.4·0.6/25) = 0.1386), which is a different number.
Choosing the test for two populations (Decision order)
1) Mean or proportion? 2) Paired (one group, two variables) or independent (two groups)? 3) Independent means: variances known (z) or unknown (t)? 4) Unknown: equal-variance test, p > 0.05 pooled, p < 0.05 Welch. 5) Proportions: pooled p̄ in the test, separate p̂ in the CI.