- Choose an appropriate method for a new question by looking at the type of response, the number of groups or predictors, the study design, and whether the conditions hold.
- Read the output of statistical software (R and Excel style) and find the estimate, standard error, test statistic, p-value, interval, and \(R^2\).
- Fit and interpret a multiple regression: partial slopes, adjusted \(R^2\), the overall F test, and the problem of multicollinearity.
- Explain odds, log-odds, and the logistic model for a yes/no response, and interpret an odds ratio.
- Carry out the sign test, Wilcoxon signed-rank test, Mann-Whitney test, Kruskal-Wallis test, and Spearman correlation, and say when they are preferable to the t and F procedures.
- Explain why running many tests inflates false positives, and apply the Bonferroni and Holm corrections.
- Write up a result honestly (estimate, interval, p-value, context, caveats) and recognize practices that make statistical claims unreliable.
- Work through three complete analyses from question to conclusion.
Fourteen chapters have given you a large toolbox: graphs and summaries, probability, sampling distributions, confidence intervals, tests for one and two groups, chi-square tests, ANOVA, and regression. This last chapter is about judgment. Real problems do not arrive labelled "Chapter 11 problem". You have to look at the question, the variables, and how the data were collected, and decide which tool fits. You will also meet three important extensions (multiple regression, logistic regression, and rank-based methods), learn to read what software prints, learn to communicate results honestly, and finish with three complete case studies.
The big picture: from a question to a method
Every method in this course answers the same kind of question: what can we say about a population or a process from a sample, and how sure are we? Choosing the method is a matter of asking four questions in order.
- What is the question, and what is the parameter? A mean, a proportion, a difference, a slope, an association? Write the hypotheses or the quantity to estimate in words before touching any formula.
- What are the variables, and what type is each? Which one is the response, and is it quantitative or categorical? Which are explanatory, and how many?
- How were the data collected? Random sample or random assignment? Are the observations independent, or paired or matched (the same subject measured twice, twins, before and after)? The design decides the method; a test that ignores pairing or clustering gives wrong answers.
- Do the conditions hold? Independence, randomness, large enough counts (success-failure, expected counts at least 5), approximate normality or a large sample, constant variance for regression and ANOVA. If a condition fails, use a robust alternative (Sections 15.6) or a different approach (simulation, permutation, transformation).
Notice what is not on the list: which method gives the smaller p-value. Selecting the test after looking at the results, until something is significant, is one of the main ways statistics goes wrong (Section 15.7).
The test-selection map
The table collects the methods of the course. Find the row that matches your response variable and your design, and read across for the standard method, the alternative when conditions fail, and the chapter where it was developed.
| Response | Situation | Standard method | If conditions fail | Chapter |
|---|---|---|---|---|
| Categorical | One group, claimed proportion | One-proportion z test and interval | Exact binomial test | 10, 6 |
| One variable with \(k\) categories, claimed distribution | Chi-square goodness of fit | Combine categories; simulate | 12 | |
| Two independent groups, compare proportions | Two-proportion z test and interval | Fisher's exact test | 11, 12 | |
| Two categorical variables (\(r \times c\) table) | Chi-square test of independence or homogeneity, residuals, odds ratio | Fisher's exact test (2 by 2); combine categories | 12 | |
| Binary response with one or more predictors | Logistic regression | (needs enough events per predictor) | 15 | |
| Quantitative | One group, claimed mean | One-sample t test and interval | Sign test, Wilcoxon signed-rank | 10, 15 |
| Two independent groups | Welch two-sample t test and interval | Permutation test, Mann-Whitney | 11, 15 | |
| Paired or matched data | Paired t test (one-sample t on the differences) | Sign test, Wilcoxon signed-rank | 11, 15 | |
| Three or more independent groups | One-way ANOVA F test, then Tukey comparisons | Kruskal-Wallis test | 13, 15 | |
| One quantitative predictor | Simple linear regression (slope test, intervals) | Transformation; Spearman correlation | 14, 4 | |
| Two or more predictors | Multiple regression | Transformation; more careful model building | 15 |
- A test is a way of asking a question, so a confidence interval usually says more. Report the interval whenever the method offers one.
- The two-sample t test, one-way ANOVA with two groups, and simple regression with a 0/1 predictor are the same test wearing different clothes (\(F = t^2\)). Do not agonize over which name to use.
- If both a parametric and a rank-based method are reasonable and they agree, report the parametric one and mention the check. If they disagree, look at the data: something (an outlier, skewness) matters.
The tool below turns the map into a wizard. Answer three questions and it tells you the method, the hypotheses, the conditions, and the R and Excel commands. Then use "Test me" to practice on realistic scenarios.
Reading software output
In practice you will rarely compute a standard error by hand. You will run software and read its output. The skill is not remembering commands; it is knowing what each number means and where to find the ones you need. Almost every output contains the same ingredients: an estimate, its standard error, a test statistic (estimate divided by standard error, or a similar ratio), a p-value, and often a confidence interval, plus a measure of fit such as \(R^2\) or the residual standard error.
- Identify the method (the title or the function that produced it) and the data it was run on.
- Find the estimate that answers your question (a mean difference, a slope, an odds ratio).
- Find its uncertainty: standard error or confidence interval.
- Find the test statistic, degrees of freedom, and p-value, and check the direction of the alternative (two-sided by default).
- Find the fit or effect size (\(R^2\), residual standard error, deviance) and decide whether the effect matters in context.
- Only then write the conclusion in words, with units.
The tool shows real R-style output for eight analyses, each computed live from data used in this course. Pick where a number lives from the menu and it is highlighted, turn on the annotations for a guided tour, or press "Quiz me" and find the number yourself.
R and Excel side by side
| Task | R | Excel |
|---|---|---|
| Two-sample t test | t.test(y ~ group, data = d) | T.TEST(range1, range2, 2, 3) gives only the p-value (tails = 2, type 3 = unequal variance) |
| Paired t test | t.test(x, y, paired = TRUE) | T.TEST(range1, range2, 2, 1) |
| Critical value | qt(0.975, df) | T.INV.2T(0.05, df) |
| Chi-square test | chisq.test(table) | CHISQ.TEST(observed, expected) |
| One-way ANOVA | summary(aov(y ~ group, d)) | Data Analysis ToolPak, "Anova: Single Factor" |
| Simple or multiple regression | summary(lm(y ~ x1 + x2, d)) | ToolPak "Regression", or LINEST(), SLOPE(), INTERCEPT(), RSQ() |
| Logistic regression | glm(y ~ x, family = binomial, d) | No built-in command (use Solver or another program) |
| Rank-based tests | wilcox.test(), kruskal.test(), cor(x, y, method = "spearman") | No built-in commands (rank with RANK.AVG() and compute) |
| Adjusted p-values | p.adjust(p, method = "holm") | Compute by hand |
| Python equivalents | scipy.stats.ttest_ind, ttest_rel, chi2_contingency, f_oneway, mannwhitneyu, wilcoxon, kruskal, linregress; statsmodels for ols and logit | |
- Check that the software used the test you intended: Welch or pooled, paired or independent, one-sided or two-sided, continuity correction or not. Defaults differ between programs.
- "p-value = 0" or "p < 2.2e-16" means "smaller than the smallest number the program prints", never exactly zero. Write \(p \lt 0.0001\).
- Output shows many digits. Report two or three significant figures, with units.
- Always plot the data first. Output can look perfect for data that are badly wrong (Anscombe's quartet, Chapter 14).
Multiple regression
Simple regression uses one explanatory variable. Most real responses depend on several things at once: a house price depends on size, age, location, and condition; blood pressure depends on age, weight, and diet. Multiple regression models a quantitative response \(y\) using \(k\) explanatory variables:
\[y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \cdots + \beta_k x_k + \varepsilon, \qquad \varepsilon \sim N(0, \sigma^2).\]The fitted equation is \(\hat{y} = b_0 + b_1 x_1 + \cdots + b_k x_k\), and the coefficients are again found by least squares, minimizing \(\sum (y_i - \hat{y}_i)^2\). With two predictors the fitted "line" becomes a plane; with more, a hyperplane we cannot draw but can still compute.
What a coefficient means
In a multiple regression, \(b_j\) is the predicted change in \(y\) for a one-unit increase in \(x_j\) with all the other predictors held fixed (adjusting for the other variables in the model).
This is the central idea, and it explains why the slope for \(x_1\) in a multiple regression can differ, even in sign, from the slope in a simple regression on \(x_1\) alone. If \(x_1\) and \(x_2\) are correlated, then in the simple regression the slope for \(x_1\) also absorbs some of the effect of \(x_2\), which travels with it. The multiple regression separates the two. This is how statisticians "control for" a variable in observational data, though only for the variables that are actually in the model. It does not turn an observational study into an experiment.
Measuring fit: \(R^2\), adjusted \(R^2\), and the overall F test
Everything you know from Chapter 14 carries over: \(\text{SST} = \text{SSR} + \text{SSE}\), and \(R^2 = \text{SSR}/\text{SST}\) is the proportion of variation explained. But there is a catch: adding any predictor, even random noise, never decreases \(R^2\). So \(R^2\) cannot be used to decide whether an extra variable earns its place. The adjusted \(R^2\) charges a penalty for each predictor:
\[R^2_{\text{adj}} = 1 - (1 - R^2)\,\frac{n-1}{n-k-1}.\]The residual standard error uses the new degrees of freedom: \(s_e = \sqrt{\text{SSE}/(n-k-1)}\). Two kinds of tests appear in every output:
- Overall F test of \(H_0\!: \beta_1 = \beta_2 = \cdots = \beta_k = 0\) (the model is no better than the mean), with \(F = \dfrac{\text{SSR}/k}{\text{SSE}/(n-k-1)} = \dfrac{R^2/k}{(1-R^2)/(n-k-1)}\) on \(k\) and \(n-k-1\) degrees of freedom.
- t tests for each coefficient, \(t = b_j/\text{SE}(b_j)\) with \(n-k-1\) degrees of freedom, testing \(H_0\!: \beta_j = 0\) given the other predictors are in the model. Confidence intervals are \(b_j \pm t^* \text{SE}(b_j)\).
Multicollinearity
When two predictors are strongly correlated they carry nearly the same information, and the model cannot tell which one deserves the credit. The individual standard errors inflate, coefficients become unstable and may even flip sign from sample to sample, yet the overall \(R^2\) and predictions can remain fine. The variance inflation factor for predictor \(j\) is
\[\text{VIF}_j = \frac{1}{1 - R_j^2},\]where \(R_j^2\) is the \(R^2\) from regressing \(x_j\) on the other predictors. With two predictors that have correlation \(r_{12}\), \(\text{VIF} = 1/(1 - r_{12}^2)\). A VIF above about 5 to 10 signals trouble; the standard error of that coefficient is \(\sqrt{\text{VIF}}\) times larger than it would be with uncorrelated predictors.
More things to know
- Categorical predictors enter through indicator (0/1) variables, one fewer than the number of categories. The coefficient of an indicator is the average difference from the reference category, adjusting for the other variables. (One-way ANOVA is exactly this model with only indicators.)
- Interactions (a product term \(x_1 x_2\)) let the effect of one variable depend on the level of another.
- Conditions are the Chapter 14 ones (linearity, independence, constant variance, normal errors), checked with residual plots against the fitted values and against each predictor. Also watch for hidden extrapolation: a combination of predictor values outside the observed cloud.
- Model selection. Compare models with adjusted \(R^2\), information criteria such as AIC, or, best of all, prediction accuracy on data not used to fit the model (cross-validation). Choosing variables by their p-values and then reporting the same p-values is a form of p-hacking. Prefer models chosen for scientific reasons.
- Do not add predictors indiscriminately. A rough rule is at least 10 to 20 observations per predictor. Too many predictors fit the noise (overfitting) and predict new data poorly.
Going deeper: The matrix form and why the formulas look the same
Stack the responses in a vector \(\mathbf{y}\) and the predictors in a matrix \(X\) whose first column is all ones. The least-squares coefficients solve the normal equations \(X^{\mathsf T} X \mathbf{b} = X^{\mathsf T} \mathbf{y}\), so \(\mathbf{b} = (X^{\mathsf T} X)^{-1} X^{\mathsf T}\mathbf{y}\). The covariance matrix of the estimates is \(s_e^2 (X^{\mathsf T}X)^{-1}\), and the standard error of \(b_j\) is the square root of its \(j\)th diagonal entry. For simple regression this reduces to \(\text{SE}(b_1) = s_e/\sqrt{S_{xx}}\), the formula of Chapter 14. The tool below solves these equations live in your browser.
The variance inflation factor appears directly: the \(j\)th diagonal entry equals \(\text{VIF}_j/((n-1)s_{x_j}^2)\) times \(s_e^2\), so correlated predictors (large \(R_j^2\)) inflate it.
The sandbox lets you build a two-predictor world. Set the true coefficients, the correlation between the predictors, and the noise, then compare what a simple regression on \(x_1\) alone says with what the multiple regression says. Try the "Confounding" and "Collinearity" presets, and load the real house-price data of Example 15.1.
Example 15.1: House prices, size, and age (synthetic data)
A real estate analyst records the sale price (thousands of dollars), floor area (square metres), and age (years) of 30 houses. The data are synthetic, generated for teaching, and are loaded in the sandbox above under "House prices (Example 15.1)".
Two simple regressions. Price on size alone: \(\widehat{\text{price}} = -20.32 + 2.048\,\text{size}\), \(R^2 = 0.840\). Price on age alone: \(\widehat{\text{price}} = 294.57 - 3.512\,\text{age}\), \(R^2 = 0.461\), \(t = -4.90\), \(p \lt 0.0001\). Taken alone, age looks like a strong predictor: each extra year is associated with a price \$3,512 lower.
The multiple regression.
| Term | Estimate | Std. error | t | p-value |
|---|---|---|---|---|
| Intercept | 24.81 | 33.35 | 0.744 | 0.463 |
| Size (m\(^2\)) | 1.825 | 0.214 | 8.522 | \(\lt 0.0001\) |
| Age (years) | -0.808 | 0.495 | -1.631 | 0.115 |
The residual standard error is \(s_e = 22.88\) on \(30 - 3 = 27\) degrees of freedom, \(R^2 = 0.854\), adjusted \(R^2 = 1 - (1-0.854)(29/27) = 0.843\), and the overall test gives \(F = 78.98\) on 2 and 27 degrees of freedom, \(p \lt 0.0001\).
Interpretation. Holding age fixed, each additional square metre is associated with a predicted price increase of \$1,825 (95 percent CI \$1,385 to \$2,264). Holding size fixed, each additional year of age is associated with a predicted change of \(-\$808\) (95 percent CI \(-\$1{,}824\) to \(+\$209\)), which is not statistically distinguishable from zero. The strong association of age with price in the simple regression was mostly a proxy effect: in these data newer houses tend to be larger (\(r = -0.64\) between size and age), and size is what drives price. The two predictors have \(\text{VIF} = 1/(1 - 0.641^2) = 1.70\), a mild overlap.
Prediction. For a 120 m\(^2\) house that is 10 years old, \(\hat{y} = 24.81 + 1.8246(120) - 0.8075(10) = 235.7\), about \$235,700.
Notice that adding age raised \(R^2\) only from 0.840 to 0.854, and the age coefficient is not significant, so a simpler model with size alone is defensible. The adjusted \(R^2\) rose slightly (0.834 to 0.843), so this is a judgment call, and subject-matter knowledge (does age matter for price in this market?) should decide.
Logistic regression
What if the response is not a number but a yes/no outcome: passed or failed, bought or did not buy, survived or did not survive, has the disease or does not? A straight-line model is a poor fit, because a line eventually gives "probabilities" below 0 or above 1. Logistic regression models the probability of success as an S-shaped function of the predictors.
Probability, odds, and log-odds
Let \(p = P(Y = 1 \mid x)\). Three equivalent ways to express the same uncertainty:
| Quantity | Formula | Range | Example (\(p = 0.75\)) |
|---|---|---|---|
| Probability | \(p\) | 0 to 1 | 0.75 |
| Odds | \(\dfrac{p}{1-p}\) | 0 to \(\infty\) | 3 (3 to 1 in favour) |
| Log-odds (logit) | \(\ln\dfrac{p}{1-p}\) | \(-\infty\) to \(\infty\) | 1.099 |
To go back: \(\text{odds} = e^{\text{logit}}\) and \(p = \dfrac{\text{odds}}{1 + \text{odds}}\). The logistic model says that the log-odds are a linear function of the predictors:
The right-hand form is the S-shaped logistic curve, always strictly between 0 and 1.
Interpreting the coefficients
A one-unit increase in \(x_1\) adds \(\beta_1\) to the log-odds, and therefore multiplies the odds by \(e^{\beta_1}\). So \(e^{\beta_1}\) is an odds ratio: if \(e^{b_1} = 4.5\), each additional unit of \(x_1\) is associated with odds of success 4.5 times as large (holding the other predictors fixed). An odds ratio of 1 (a coefficient of 0) means no association; below 1, a decrease in odds. The effect on the probability is not constant: it is largest where \(p\) is near 0.5 and small near 0 or 1. The odds ratio of Chapter 12 is the special case of a single 0/1 predictor.
Fitting: maximum likelihood
Least squares does not work here. Instead we choose the coefficients that make the observed data most probable. The likelihood is \(L = \prod p_i^{y_i}(1-p_i)^{1-y_i}\), and we maximize \(\ln L\). There is no formula for the answer; software finds it by an iterative algorithm (Newton-Raphson, called iteratively reweighted least squares in this setting). The deviance is \(-2\ln L\), the analogue of SSE: smaller is better fit.
Inference
- Wald test for a coefficient: \(z = b_j/\text{SE}(b_j)\), compared with the standard normal. A Wald confidence interval for the odds ratio is \(\exp(b_j \pm z^*\text{SE}(b_j))\).
- Likelihood-ratio test of the whole model: the drop in deviance from the null model (intercept only) to the fitted model, \(G = D_{\text{null}} - D_{\text{model}}\), is compared with a chi-square distribution with \(k\) degrees of freedom. It plays the role of the overall F test.
- Classification. Predict "success" when \(\hat{p} \ge 0.5\) (or another threshold). Summarize with the confusion matrix: sensitivity (proportion of true successes caught) and specificity (proportion of true failures caught). Accuracy depends heavily on how common successes are, so report both kinds of error.
Independent observations, a binary response, a log-odds relationship that is roughly linear in each quantitative predictor, and enough data: a common guideline is at least 10 successes and 10 failures per predictor. There is no "constant variance" or "normal errors" condition, which is why logistic regression is the right tool for yes/no data.
Explore the model below. The tool starts with a classic teaching example: 20 students, hours spent studying for an exam, and whether each passed. Move the sliders to build your own curve, watch the log-likelihood, then let the computer find the maximum-likelihood fit.
Example 15.2: Hours of study and passing an exam
Twenty students report the hours they studied and whether they passed (a commonly used teaching data set; it is preloaded in the tool). Maximum likelihood gives
| Term | Estimate | Std. error | z | p-value |
|---|---|---|---|---|
| Intercept | -4.078 | 1.761 | -2.316 | 0.0206 |
| Hours | 1.505 | 0.629 | 2.393 | 0.0167 |
The fitted model is \(\ln\dfrac{\hat{p}}{1-\hat{p}} = -4.078 + 1.505\,\text{hours}\).
Odds ratio. \(e^{1.505} = 4.50\): each additional hour of study is associated with pass odds 4.5 times as large. A Wald 95 percent interval is \(\exp(1.505 \pm 1.96 \times 0.629) = (1.31, 15.4)\), wide because \(n = 20\).
Predicted probabilities. At 2 hours the log-odds are \(-4.078 + 1.505(2) = -1.069\), odds \(e^{-1.069} = 0.343\), so \(\hat{p} = 0.343/1.343 = 0.256\). At 3 hours, \(\hat{p} = 0.607\); at 4 hours, \(\hat{p} = 0.874\). The pass probability crosses 0.5 at \(x = 4.078/1.505 = 2.71\) hours. Notice the probability rises by 0.35 from 2 to 3 hours but only 0.27 from 3 to 4: the effect on the probability is not constant, though the effect on the log-odds is.
Overall fit. The null deviance is 27.726 on 19 degrees of freedom and the residual deviance is 16.060 on 18. The likelihood-ratio statistic is \(G = 27.726 - 16.060 = 11.67\) on 1 degree of freedom, \(p = 0.0006\): strong evidence that hours studied is related to passing.
Classification at threshold 0.5: 8 of 10 passes and 8 of 10 failures are predicted correctly, an accuracy of 16/20 = 80 percent (sensitivity 0.80, specificity 0.80).
Nonparametric (rank-based) methods
The t and F procedures assume that the data (or the sampling distribution of the mean) are approximately normal. For moderate or large samples the Central Limit Theorem rescues us. For small samples with strong skewness or outliers, or for ordinal data (ratings such as "poor, fair, good, excellent"), rank-based methods are a sound alternative. They replace the raw values by their ranks (1 for the smallest, and so on, with ties given the average rank), so a single wild outlier can be at most the largest rank and can no longer dominate. They make far fewer assumptions and are sometimes called distribution-free or nonparametric.
| Design | Parametric test | Rank-based counterpart |
|---|---|---|
| One sample or paired differences | One-sample or paired t | Sign test; Wilcoxon signed-rank test |
| Two independent samples | Welch two-sample t | Mann-Whitney U (Wilcoxon rank-sum) test |
| Three or more independent samples | One-way ANOVA | Kruskal-Wallis test |
| Association of two variables | Pearson correlation and slope test | Spearman rank correlation |
The sign test
The simplest rank-free idea. For paired data (or one sample against a claimed median \(m_0\)), record only the sign of each difference and discard zeros. If there is no effect, each nonzero difference is positive with probability 1/2, so the number of positive signs \(B\) among \(n\) nonzero differences is Binomial\((n, 1/2)\). The two-sided p-value is \(2\,P(B \ge b)\) for \(b \gt n/2\) (or \(2\,P(B \le b)\) if \(b \lt n/2\)), capped at 1. It requires almost nothing of the data but discards magnitudes, so it has lower power than the alternatives below.
The Wilcoxon signed-rank test
Uses both the signs and the sizes of paired differences. Drop zeros, rank the absolute differences \(|d_i|\) from 1 to \(n\), and add up the ranks of the positive differences, \(W^+\), and of the negative ones, \(W^-\) (so \(W^+ + W^- = n(n+1)/2\)). The statistic is \(W = \min(W^+, W^-)\); a very small value is evidence against "no effect". For larger \(n\), \(W^+\) is approximately normal with
\[\mu_W = \frac{n(n+1)}{4}, \qquad \sigma_W^2 = \frac{n(n+1)(2n+1)}{24} \;\text{(reduced slightly when there are ties)}.\]The Mann-Whitney (Wilcoxon rank-sum) test
For two independent samples of sizes \(n_1\) and \(n_2\), pool all \(N = n_1 + n_2\) values, rank them, and let \(R_1\) be the sum of the ranks of sample 1. The Mann-Whitney statistic is
\[U_1 = R_1 - \frac{n_1(n_1+1)}{2},\qquad U_1 + U_2 = n_1 n_2.\]\(U_1\) counts the pairs (one from each sample) in which the sample-1 value is the larger. If the groups have the same distribution, \(U_1\) has mean \(n_1n_2/2\) and variance \(n_1n_2(N+1)/12\) (adjusted for ties); a \(U\) far from its mean is evidence that one group tends to give larger values. The null hypothesis is that the two distributions are the same; if the distributions have the same shape, it becomes a statement about their medians. For small samples with no ties the exact p-value can be computed by listing all the possible rank arrangements.
The Kruskal-Wallis test
The rank-based version of one-way ANOVA. Rank all \(N\) observations together and let \(R_i\) be the sum of the ranks in group \(i\), which has \(n_i\) observations. Then
\[H = \frac{12}{N(N+1)}\sum_{i=1}^{k}\frac{R_i^2}{n_i} - 3(N+1),\]which is compared with a chi-square distribution with \(k-1\) degrees of freedom (when every group has at least about 5 observations). A large \(H\) means the rank sums differ more than chance allows. If it is significant, follow up with pairwise Mann-Whitney tests using a multiple-comparison correction (Section 15.7).
Spearman rank correlation
The Spearman correlation \(r_s\) is the ordinary Pearson correlation of the ranks. It measures how well the relationship follows a monotone (always increasing or always decreasing) pattern, whether or not it is a straight line, and is unaffected by outliers in the way Pearson \(r\) is. When there are no ties, \(r_s = 1 - \dfrac{6\sum d_i^2}{n(n^2-1)}\), where \(d_i\) is the difference between the two ranks of observation \(i\).
- When the data really are normal, rank tests are about 95 percent as powerful as the t test (a Wilcoxon test needs about 5 percent more data for the same power). When the data are heavy-tailed, they can be much more powerful. So switching to a rank test costs little and can help a lot.
- Rank tests answer a different question: "do values in one group tend to be larger?" rather than "do the means differ?". They do not produce a confidence interval for a mean difference as easily.
- They still require independence and, for a fair reading as a comparison of medians, similarly shaped distributions. They do not rescue a biased sample.
- With small samples and ties, the normal approximation is only rough; exact or permutation p-values are better.
The calculator below runs all four tests on your own data. It shows the ranks, the statistic, an exact p-value when the sample is small and has no ties (otherwise a normal approximation with tie and continuity corrections), and the matching t or F test for comparison. Try the presets, then edit the numbers to see how one outlier affects the t test but barely moves the rank test.
Example 15.3: Mann-Whitney by hand: two teaching methods
Five students learn a skill by method A and five by method B. Their test scores are A: 14, 22, 17, 30, 25 and B: 28, 34, 26, 41, 38. Do the methods differ?
Rank the pooled data (10 values): 14 (1), 17 (2), 22 (3), 25 (4), 26 (5), 28 (6), 30 (7), 34 (8), 38 (9), 41 (10). The sample-A ranks are 1, 3, 2, 7, 4, so \(R_A = 17\) (and \(R_B = 38\); check: \(17 + 38 = 55 = 10 \cdot 11/2\)).
Statistic. \(U_A = 17 - 5(6)/2 = 2\) and \(U_B = 25 - 2 = 23\). The mean of \(U\) under the null hypothesis is \(n_An_B/2 = 12.5\); \(U_A = 2\) is very low.
P-value. Enumerating all \(\binom{10}{5} = 252\) equally likely rank assignments gives an exact two-sided p-value of \(0.0317\). The normal approximation with continuity correction gives 0.0367. For comparison, the Welch t test gives \(t = -2.93\), \(p = 0.019\).
Conclusion. There is fairly strong evidence (\(p = 0.032\)) that scores under method B tend to be higher than under method A.
Example 15.4: Signed-rank by hand, and a tale of two tests
Seven patients are measured before and after a treatment; the changes (after minus before) are \(4, -1, 6, 3, -2, 8, 5\).
Rank the absolute values \(|d|\): 1, 2, 3, 4, 5, 6, 8 receive ranks 1, 2, 3, 4, 5, 6, 7. The negative changes are \(-1\) (rank 1) and \(-2\) (rank 2), so \(W^- = 3\) and \(W^+ = 28 - 3 = 25\), where \(n(n+1)/2 = 28\). The test statistic is \(W = 3\).
P-value. Of the \(2^7 = 128\) equally likely sign patterns, 10 give \(W \le 3\) or \(W \ge 25\), so the exact two-sided p-value is \(10/128 = 0.078\). The paired t test on the same data gives \(t = 2.39\), \(\text{df} = 6\), \(p = 0.054\).
Conclusion. Neither test reaches the 5 percent level. There is only weak evidence of an effect; with seven patients that is unsurprising. The sign test on the same data (5 positive, 2 negative) gives \(p = 0.453\), illustrating how much power is lost by ignoring magnitudes.
Example 15.5: Kruskal-Wallis and Spearman by formula
Kruskal-Wallis. Three groups of four: G1: 27, 31, 29, 35; G2: 33, 38, 36, 40; G3: 45, 41, 47, 43. Ranking all 12 values gives rank sums \(R_1 = 11\), \(R_2 = 25\), \(R_3 = 42\) (check: \(11 + 25 + 42 = 78 = 12 \cdot 13/2\)). Then
\[H = \frac{12}{12 \cdot 13}\left(\frac{11^2 + 25^2 + 42^2}{4}\right) - 3(13) = \frac{12}{156}(627.5) - 39 = 9.269,\]with \(\text{df} = 2\) and \(p = 0.0097\). The groups are clearly not the same. (The ordinary F test gives \(F = 20.1\), \(p = 0.0005\).)
Spearman. Six items are ranked by two judges: judge 1 ranks \(3, 1, 4, 6, 5, 2\) and judge 2 ranks \(2, 1, 3, 6, 4, 5\). The rank differences are \(1, 0, 1, 0, 1, -3\), so \(\sum d^2 = 12\) and \(r_s = 1 - 6(12)/(6 \cdot 35) = 0.657\). With \(n = 6\) this is not significant (\(p = 0.156\)): six pairs is too few to distinguish a moderate correlation from chance.
Many tests, one dataset: the multiple comparisons problem
A single test at \(\alpha = 0.05\) has a 5 percent chance of a false alarm when the null hypothesis is true. But suppose you run \(m\) independent tests, all with true null hypotheses. The probability of at least one false positive, the family-wise error rate, is
\[\text{FWER} = 1 - (1 - \alpha)^m.\]For \(m = 1, 5, 10, 20, 100\) this is 0.05, 0.226, 0.401, 0.642, and 0.994. Test twenty unrelated things and you should expect one "significant" result. This is how a cherry-picked result, a subgroup analysis nobody planned, or a search through dozens of variables for "something interesting" produces headlines that later fail to replicate. Note that you do not need to run the tests on purpose: comparing many outcomes, many subgroups, many time points, or many model specifications are all "tests", even if only the significant ones are reported.
- Bonferroni. Reject test \(i\) only if \(p_i \le \alpha/m\). Simple, guarantees FWER \(\le \alpha\) whatever the dependence, but conservative when \(m\) is large. Equivalent: multiply each p-value by \(m\) (cap at 1).
- Holm (step-down). Sort the p-values \(p_{(1)} \le \cdots \le p_{(m)}\). Compare \(p_{(1)}\) with \(\alpha/m\), \(p_{(2)}\) with \(\alpha/(m-1)\), and so on, and stop at the first failure; reject everything before it. Always at least as powerful as Bonferroni with the same guarantee, so prefer it.
- Tukey's method (Chapter 13) is the right adjustment for all pairwise comparisons of group means after an ANOVA.
- False discovery rate (Benjamini-Hochberg). Controls the expected proportion of false discoveries among the results declared significant, instead of the chance of any error. Common in genomics and other settings with thousands of tests, where Bonferroni would find nothing.
Example 15.6: Bonferroni versus Holm
A study tests five outcomes and obtains p-values 0.004, 0.011, 0.012, 0.030, 0.20 with overall \(\alpha = 0.05\).
Bonferroni: the threshold is \(0.05/5 = 0.01\). Only 0.004 passes. One rejection.
Holm: \(0.004 \le 0.05/5 = 0.010\) (reject); \(0.011 \le 0.05/4 = 0.0125\) (reject); \(0.012 \le 0.05/3 = 0.0167\) (reject); \(0.030 \le 0.05/2 = 0.025\)? No, so stop. Three rejections, with the same guarantee against any false positive.
The simulator below makes the problem visible. It runs \(m\) two-sample t tests on data where nothing is going on (both groups are drawn from the same normal distribution), so every "significant" result is a false alarm. See how many turn up, then repeat the experiment hundreds of times to watch the family-wise error rate match the formula, and see what the corrections do.
Even without running many tests on purpose, a researcher who decides after seeing the data which variable to test, which outliers to drop, which subgroup to report, how to code a variable, or when to stop collecting data has effectively run many tests. Statisticians call this the garden of forking paths, and the deliberate version p-hacking. The remedies are to state the analysis plan before collecting the data (pre-registration), separate exploratory analyses (which generate hypotheses and must be labelled as such) from confirmatory ones, correct for the number of comparisons actually made, report all analyses run, and replicate surprising findings.
Communicating results
A correct analysis that is poorly communicated is only half a result. Good statistical writing is short, specific, and honest. A complete summary of an inference has these parts, in roughly this order:
- Context and question in plain language: who or what, and what was compared.
- Design and sample: how the data were collected, sample size, any missing data or exclusions.
- Estimate with a confidence interval and units: "the mean difference was 1.58 hours (95 percent CI 0.70 to 2.46)".
- Test statistic, degrees of freedom, and p-value (exact, or \(p \lt 0.001\)), naming the test used.
- A measure of the size of the effect that a reader can judge (\(R^2\), Cohen's \(d\), an odds ratio, a difference in the original units).
- Conclusion in context, worded to match the design (association, or cause only if there was random assignment).
- Caveats: conditions checked, limitations, generalization (to what population?).
Wording that says what the evidence supports
| Avoid | Prefer |
|---|---|
| "The p-value is 0.03, so there is a 97 percent chance the drug works." | "If the drug had no effect, data this extreme would occur about 3 percent of the time." |
| "We accept the null hypothesis." | "We do not have enough evidence to conclude a difference." |
| "Not significant, so there is no effect." | "The interval (-0.4, 2.1) is consistent with anything from a small decrease to a moderate increase." |
| "Significant" (used loosely) | "Statistically significant at the 5 percent level, and the effect (0.3 points) is too small to matter in practice." |
| "Coffee drinking causes longer life." | "Coffee drinkers in this observational study lived longer on average; confounding is possible." |
| "The correlation is 0.4, so 40 percent is explained." | "\(r^2 = 0.16\): 16 percent of the variation in \(y\) is explained by the linear relationship." |
Statistical versus practical significance
With a large sample, a trivially small difference becomes statistically significant; with a small sample, a large and important difference may not. The p-value depends on the sample size and the effect; it says nothing about how big the effect is. Always report an effect size. Common ones: the raw difference or slope in the original units (best, when units are meaningful), \(R^2\) or \(\eta^2 = \text{SSB}/\text{SST}\) (proportion of variance explained), Cohen's \(d = (\bar{x}_1 - \bar{x}_2)/s_p\) (difference in pooled standard deviations; rough benchmarks: 0.2 small, 0.5 medium, 0.8 large, to be treated with caution), and odds ratios or relative risks for categorical outcomes.
Graphs that communicate
- Show the data, not just summaries: dotplots or jittered points next to boxplots, scatterplots with the fitted line and an interval band.
- Label axes with variable names and units, start bar charts at zero, and avoid 3-D effects and decorative clutter.
- Show uncertainty (error bars or bands) and say what it is: standard error, 95 percent confidence interval, or standard deviation.
- Use the same scale when panels are meant to be compared, and put the comparison of interest side by side.
Example 15.7: Three model write-ups
A two-group comparison. "We compared plant growth under two treatments, with 10 randomly assigned plants each. Mean dry weight was 5.53 g (SD 0.44) under treatment 2 and 4.66 g (SD 0.79) under treatment 1. The mean difference was 0.87 g (Welch 95 percent CI 0.25 to 1.48 g; \(t(14.1) = 3.01\), \(p = 0.009\); Cohen's \(d = 1.35\)). Because the treatments were randomly assigned, the difference can be attributed to the treatments. The small sample and the single growing season limit generalization."
A regression. "Among 50 cars in a 1920s dataset, stopping distance increased with speed. Each additional mile per hour was associated with an increase of 3.93 feet in predicted stopping distance (95 percent CI 3.10 to 4.77; \(t(48) = 9.46\), \(p \lt 0.001\)); speed explained 65 percent of the variation in distance (\(R^2 = 0.651\)). The residual plot showed increasing spread at high speeds, so predictions for fast cars are less precise than for slow ones. Stopping distance should not be extrapolated beyond the observed speeds of 4 to 25 mph."
A logistic regression. "Among 20 students, the odds of passing were 4.5 times larger for each additional hour of study (OR 4.50, 95 percent CI 1.31 to 15.4; \(p = 0.017\)). The model classified 80 percent of students correctly. Because the sample is small, the interval is wide, and because study time was self-reported and not assigned, the association should not be read as causal."
Ethics, reproducibility, and reading claims critically
Statistics is a tool for finding out what is true, and it can be abused. Ethical practice is not an add-on; it is part of the method. The American Statistical Association's Ethical Guidelines for Statistical Practice and its 2016 statement on p-values both emphasize the same themes.
Treating people and data responsibly
- Consent and oversight. Research on people needs informed consent and review by an ethics board (an IRB in the United States). Experiments must not expose participants to unreasonable risk; randomizing a treatment is ethical only when there is genuine uncertainty about which option is better.
- Privacy. Individuals can often be re-identified from supposedly anonymous data (age, postcode, and gender together can be unique). Collect the minimum, protect it, and aggregate before publishing.
- Representation and fairness. A model trained on data that under-represents a group will serve that group poorly. Predictive models (for lending, hiring, or policing) can reproduce historical bias, and a model that is equally accurate for two groups can still make errors of different kinds for each. Ask who is missing from the data and who bears the cost of errors.
Reporting honestly
- Report all analyses performed and all results, including the disappointing ones. Publishing only significant results distorts the literature (publication bias).
- Do not remove outliers just because they spoil the result; state any exclusion rule in advance and report results with and without them.
- Do not present exploratory findings as confirmatory, and do not present an observational association as a causal effect.
- Disclose funding and conflicts of interest, and be as clear about limitations as about findings.
Reproducibility and the replication crisis
A result is reproducible if someone else, given your data and code, can obtain the same numbers; it replicates if a new study, with new data, finds the same effect. In a large 2015 project, the Open Science Collaboration attempted to replicate 100 published psychology experiments: about 97 percent of the originals had reported statistically significant results, but only about 36 percent of the replications did. Similar concerns arose in other fields. The main culprits are the ones you have now met: small samples, low power, many comparisons, flexible analysis, and selective reporting. Good habits that help:
- Script the analysis (R, Python, or a documented spreadsheet) instead of clicking, set the random seed, and keep raw data unchanged and separate from cleaned data.
- Keep a data dictionary: what each variable means, its units, how missing values are coded.
- Use version control and share code and data where privacy allows.
- Plan the sample size with a power calculation (Chapter 10), and pre-register the analysis plan.
- Prefer estimates and intervals to bare verdicts, and treat one significant result as a lead, not a discovery.
- Who was studied, and how were they chosen? Does the sample represent the population the claim is about?
- Was it an experiment (random assignment) or an observational study? Could confounding explain it?
- How big is the effect, and how uncertain? Is there an interval, or only a verdict?
- How many things were tested, and were the tests chosen before or after seeing the data?
- Is the effect practically important, or only statistically significant?
- Do the graph and the numbers agree (axes, scales, missing groups)?
- Who paid for it, and has anyone replicated it?
Three complete case studies
Now put the whole course to work. Each case follows the same path: question, data, look at the data, choose the method (using the map of Section 15.2), check conditions, compute, conclude, and write up. Use the tools above with the data loaded as indicated to reproduce every number.
Case study A: Which drug gives more extra sleep? (paired data and rank tests)
Question. In 1908 W. S. Gosset, writing as "Student", published the paired t test using data on the extra hours of sleep gained by 10 patients when given each of two sleep-inducing drugs (labelled 1 and 2; the data are a classic teaching example built into R as sleep). Does drug 2 give more extra sleep than drug 1?
| Patient | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|---|---|---|---|---|---|---|---|---|---|---|
| Drug 1 | 0.7 | -1.6 | -0.2 | -1.2 | -0.1 | 3.4 | 3.7 | 0.8 | 0.0 | 2.0 |
| Drug 2 | 1.9 | 0.8 | 1.1 | 0.1 | -0.1 | 4.4 | 5.5 | 1.6 | 4.6 | 3.4 |
| Difference (2 minus 1) | 1.2 | 2.4 | 1.3 | 1.3 | 0.0 | 1.0 | 1.8 | 0.8 | 4.6 | 1.4 |
Method. The same patient received both drugs, so the data are paired: analyse the ten differences (Chapter 11). The parameter is \(\mu_d\), the mean difference in extra sleep; \(H_0\!: \mu_d = 0\), \(H_a\!: \mu_d \ne 0\).
Look at the data. Nine of the ten differences are positive, one is zero, and one (4.6) is much larger than the rest, so the distribution is right-skewed with \(n = 10\). The normality condition is doubtful, which is a reason to run a rank test as a check.
Paired t. \(\bar{d} = 1.58\), \(s_d = 1.230\), \(\text{SE} = 1.230/\sqrt{10} = 0.389\), \(t = 4.062\) on 9 degrees of freedom, \(p = 0.0028\); the 95 percent CI for \(\mu_d\) is \((0.70, 2.46)\) hours. Effect size \(d_z = 1.58/1.230 = 1.28\).
Rank-based checks. Drop the zero difference (\(n = 9\)). Sign test: all 9 nonzero differences are positive, \(p = 2(1/2)^9 = 0.0039\). Wilcoxon signed-rank: \(W^- = 0\), \(W^+ = 45\); using the normal approximation with tie and continuity corrections (two of the differences tie at 1.3), \(p = 0.0091\).
A wrong analysis. Ignoring the pairing and using the Welch two-sample t test on drug 1 versus drug 2 gives \(t = 1.86\), \(\text{df} = 17.8\), \(p = 0.079\), which is not significant. The patients differ greatly in how much they sleep (the SD within a drug is about 2 hours), and that patient-to-patient variability swamps the difference of 1.58 hours. Pairing removes it. The design decides the method.
Conclusion. All three valid analyses agree: drug 2 gives more extra sleep than drug 1, by an estimated 1.58 hours (95 percent CI 0.70 to 2.46 hours; paired \(t(9) = 4.06\), \(p = 0.003\)). Caveat: only 10 patients, and it is not stated whether the order of the drugs was randomized, so order effects cannot be ruled out.
Reproduce it in the calculator of Section 15.6 by choosing "Wilcoxon signed-rank" and the preset "Sleep data (paired)".
Case study B: Do treatments change plant growth? (ANOVA, Tukey, Kruskal-Wallis)
Question. An experiment compares the dry weight of 30 plants randomly assigned to a control and two treatments (10 each). This is the well-known PlantGrowth data set from R.
| Group | Weights | Mean | SD |
|---|---|---|---|
| Control | 4.17, 5.58, 5.18, 6.11, 4.50, 4.61, 5.17, 4.53, 5.33, 5.14 | 5.032 | 0.583 |
| Treatment 1 | 4.81, 4.17, 4.41, 3.59, 5.87, 3.83, 6.03, 4.89, 4.32, 4.69 | 4.661 | 0.794 |
| Treatment 2 | 6.31, 5.12, 5.54, 5.50, 5.37, 5.29, 4.92, 6.15, 5.80, 5.26 | 5.526 | 0.443 |
Method. One quantitative response, three independent groups, random assignment: one-way ANOVA (Chapter 13). \(H_0\!: \mu_C = \mu_1 = \mu_2\).
Conditions. Randomized, independent plants. The SDs range from 0.44 to 0.79 (ratio 1.8, under the rule of thumb of 2), and Levene's test does not object (\(p = 0.34\)). Dotplots show no strong skewness or outliers. The conditions are reasonable.
ANOVA table.
| Source | SS | df | MS | F | p-value |
|---|---|---|---|---|---|
| Between groups | 3.766 | 2 | 1.8832 | 4.846 | 0.0159 |
| Within groups | 10.492 | 27 | 0.3886 | ||
| Total | 14.258 | 29 |
The effect size is \(\eta^2 = 3.766/14.258 = 0.264\): the treatment groups explain about 26 percent of the variation in weight.
Which groups differ? Because the F test is significant, follow up with Tukey's HSD, which controls the family-wise error rate over all three comparisons:
| Comparison | Difference | 95 percent CI | Adjusted p |
|---|---|---|---|
| Treatment 2 minus treatment 1 | 0.865 | (0.174, 1.556) | 0.012 |
| Treatment 2 minus control | 0.494 | (-0.197, 1.185) | 0.198 |
| Treatment 1 minus control | -0.371 | (-1.062, 0.320) | 0.391 |
Robustness check. Kruskal-Wallis gives \(H = 7.99\), \(\text{df} = 2\), \(p = 0.018\), agreeing with the F test.
Conclusion. There is evidence that mean plant weight differs among the three groups (\(F(2, 27) = 4.85\), \(p = 0.016\), \(\eta^2 = 0.26\)). Only treatment 2 and treatment 1 differ detectably: plants in treatment 2 weighed 0.87 g more on average (Tukey 95 percent CI 0.17 to 1.56 g). Neither treatment differs detectably from the control. Notice that the omnibus test being significant does not mean every pair differs. Random assignment supports a causal reading, subject to the usual limits of a small single experiment.
Reproduce it with "PlantGrowth (3 groups)" in the ANOVA tool of Chapter 13 or the Kruskal-Wallis preset in Section 15.6.
Case study C: What drives house prices? (multiple regression and diagnostics)
Question. Continuing Example 15.1: an analyst wants to explain the sale price of a house from its size and age, and to predict the price of a new listing. The 30 (synthetic) houses are in the sandbox.
Explore. Scatterplots show price rising with size and falling with age, and the predictors are correlated (\(r = -0.64\)): newer houses in the sample are larger. Correlated predictors are the first warning sign that simple slopes may mislead.
Method. Quantitative response, two quantitative predictors: multiple regression. (Simple regression on each alone is a useful comparison but not the answer.) Fit price on size and age.
Result. \(\widehat{\text{price}} = 24.81 + 1.825\,\text{size} - 0.808\,\text{age}\); \(R^2 = 0.854\), adjusted \(R^2 = 0.843\), \(s_e = 22.88\) (thousand dollars), overall \(F(2, 27) = 78.98\), \(p \lt 0.0001\). Size is highly significant (\(t = 8.52\), \(p \lt 0.0001\)); age is not, once size is accounted for (\(t = -1.63\), \(p = 0.115\)).
Check the conditions. Residuals against fitted values and against each predictor should be structureless (use the diagnostics idea of Chapter 14), the normal probability plot of the residuals close to a line, and no house with unusually high leverage or Cook's distance. Multicollinearity is mild (\(\text{VIF} = 1.70\)). Because the houses are a synthetic sample, no independence or randomness claims can be made; for real data you would ask how the sample was chosen.
Comparing models. Size alone: \(R^2 = 0.840\), adjusted 0.834, \(s_e = 23.54\). Size and age: 0.854, 0.843, 22.88. The improvement is small, the age term is not significant, and the simpler model is easier to explain. The choice should also rest on what is known about the housing market.
Conclusion and write-up. "Among 30 houses, floor area was strongly associated with price: holding age fixed, each extra square metre was associated with a predicted price \$1,825 higher (95 percent CI \$1,385 to \$2,264; \(p \lt 0.001\)). Age was strongly associated with price when considered alone (\(-\$3,512\) per year), but its association was small and not statistically significant after adjusting for size (\(-\$808\) per year; 95 percent CI \(-\$1{,}824\) to \(+\$209\)), because newer houses in the sample tend to be larger. The model explained 85 percent of the variation in prices (adjusted \(R^2 = 0.843\)); a typical prediction error is about \$23,000. Predictions should be limited to houses within the observed range of size (60 to 162 m\(^2\)) and age (3 to 45 years)."
Prediction interval. For a 120 m\(^2\), 10-year-old house, the point prediction is \$235,700. A 95 percent prediction interval for a single sale uses \(t^*(27) = 2.052\) and the leverage \(h_0 = 0.113\) of this combination of size and age: \(235.7 \pm 2.052 \times 22.88 \times \sqrt{1 + 0.113} = 235.7 \pm 49.5\), that is, from about \$186,200 to \$285,200. The interval for the mean price of all such houses is much narrower, \(235.7 \pm 2.052 \times 22.88 \times \sqrt{0.113} = 235.7 \pm 15.8\).
Where next?
You now have a solid foundation: you can describe data, understand chance, and make careful inferences for means, proportions, categorical associations, group differences, and regression relationships. This chapter has previewed three doorways. Here is where each leads.
| If you enjoyed... | Continue with |
|---|---|
| The mathematics of chance, distributions, and estimation | Probability and mathematical statistics: expectation, moment generating functions, maximum likelihood, sufficiency, the Neyman-Pearson lemma (needs calculus) |
| Regression and prediction | Regression modelling: multiple and polynomial regression, interactions, generalized linear models (logistic and Poisson regression), model selection, regularization (ridge and lasso) |
| Designing studies and experiments | Design of experiments: factorial designs, blocking, two-way ANOVA, repeated measures; survey sampling methodology |
| Learning from data with computers | Data science and machine learning: cross-validation, classification, trees and forests, cluster analysis; programming in R or Python |
| Updating beliefs with evidence | Bayesian statistics: priors, posteriors, credible intervals, Markov chain Monte Carlo |
| Data over time | Time series: trend, seasonality, autocorrelation, ARIMA and forecasting |
| Causal questions from observational data | Causal inference: potential outcomes, propensity scores, instrumental variables, natural experiments |
Whatever direction you take, keep three habits from this course: look at the data first, ask how the data were collected, and report uncertainty honestly. Appendix A collects every formula in one place, Appendix B has live statistical tables, and Appendix C offers two full practice exams to test yourself.
Chapter summary
- Choose a method by the question, the variable types, the design (independent or paired, random sampling or assignment), and whether the conditions hold. Never choose by which p-value you prefer.
- Reading output: method, estimate, standard error, test statistic and df, p-value, interval, fit measure; then a conclusion in context with units.
- Multiple regression: \(\hat{y} = b_0 + b_1x_1 + \cdots + b_kx_k\); \(b_j\) is the change in \(y\) per unit \(x_j\) holding the others fixed; \(R^2_{\text{adj}} = 1 - (1-R^2)(n-1)/(n-k-1)\); overall \(F = \dfrac{R^2/k}{(1-R^2)/(n-k-1)}\); t tests with \(n-k-1\) df; \(\text{VIF}_j = 1/(1-R_j^2)\).
- Logistic regression: \(\ln\frac{p}{1-p} = \beta_0 + \beta_1x\); \(p = 1/(1+e^{-(\beta_0+\beta_1x)})\); \(e^{\beta_1}\) is the odds ratio; fitted by maximum likelihood; Wald z tests and likelihood-ratio (deviance) tests.
- Rank methods (sign, Wilcoxon signed-rank, Mann-Whitney \(U_1 = R_1 - n_1(n_1+1)/2\), Kruskal-Wallis \(H\), Spearman \(r_s\)) suit small skewed or ordinal data, at small cost in power.
- \(m\) true nulls give FWER \(= 1-(1-\alpha)^m\). Bonferroni: \(p_i \le \alpha/m\). Holm: step-down thresholds \(\alpha/(m-i+1)\). Pre-registration and honest reporting guard against p-hacking.
- Report estimate, interval, test, effect size, context, and caveats. Distinguish statistical from practical significance and association from causation.
Key terms
| Term | Meaning |
|---|---|
| Multiple regression | Regression of a quantitative response on two or more explanatory variables |
| Partial slope | The change in \(y\) per unit change in one predictor, holding the others fixed |
| Adjusted \(R^2\) | \(R^2\) penalized for the number of predictors |
| Multicollinearity, VIF | Strong correlation among predictors, which inflates standard errors; the variance inflation factor measures it |
| Odds, log-odds (logit) | \(p/(1-p)\) and its natural logarithm |
| Logistic regression | Model in which the log-odds of a binary response are linear in the predictors |
| Odds ratio | The factor by which the odds are multiplied, \(e^{\beta}\) per unit of the predictor |
| Likelihood, deviance | Probability of the data given the parameters, and \(-2\) times its logarithm |
| Nonparametric (rank-based) test | A test based on ranks that does not assume a normal population |
| Sign test, Wilcoxon signed-rank, Mann-Whitney, Kruskal-Wallis | Rank-based counterparts of the one-sample or paired t, two-sample t, and one-way ANOVA |
| Spearman correlation | The Pearson correlation of the ranks; measures monotone association |
| Family-wise error rate | The probability of at least one false positive among a family of tests |
| Bonferroni, Holm | Corrections that keep the family-wise error rate at \(\alpha\) |
| p-hacking, forking paths | Flexible analysis choices that make significant results too likely |
| Pre-registration | Recording the analysis plan before collecting or examining the data |
| Reproducible, replicable | Same data and code give the same numbers; new data give the same finding |
| Effect size | A measure of how large an effect is, independent of the sample size |