Contents/ Part XXVII · Capstone Projects: Statistical Testing/ Chapter 159

The Analysis Framework

The next sixteen chapters are full projects, each one taking a real, messy dataset from a plain-English question to a defensible answer. They all walk the same twelve-step path. Learn it once here and every capstone becomes a variation on a theme: know your data, check before you test, choose deliberately, and report the whole truth.

⏱️ ~18 min read
🧭 Framework guide
📊 Chapter 159

Everything in this book so far has been a piece of a puzzle: describing data, visualizing it, cleaning it, the logic of a test, the family of tests, effect sizes, correlation. A capstone puts the pieces together on one real problem, start to finish. The hard part is rarely the arithmetic, which a single line of Python now handles. The hard part is judgment: what kind of data is this, what is actually being asked, do the assumptions hold, and if they do not, what then? This chapter is the shared playbook for all of it.

🧭
A capstone analysis is a complete study built on one repeatable framework: classify the data type, understand the goal, describe and visualize, prepare and clean, identify the groups and design, check the assumptions, choose and run the right test, and report the result with an effect size, an interval, and an honest look at its limits.
🗺️
The whole method in one line

Let the data type and design narrow the choice, let the assumptions settle it, run the test, and finish with an effect size, a confidence interval, and the ethics, never a bare p-value. Every capstone ahead follows exactly this arc, out loud.

1

The Twelve-Step Framework

The same twelve steps, grouped into four phases, run through every project. The first phase decides what you are studying, the middle two get the data honest and pick a valid test, and the last one turns a number into a decision. Skipping a step is where analyses go wrong: choosing a test before checking its assumptions, or reporting a p-value with no sense of how big the effect is.

One framework, four phases, twelve steps 1 · FRAME 1Goal & H₀/H₁ 2Data types 2 · EXPLORE & PREP 3Describe 4Visualize 5Clean & prep 6Design 3 · VALIDATE & CHOOSE 7Assumptions 8Decide & fix 9Choose test 4 · TEST & CONCLUDE 10Run & report 11Interpret 12Ethics & bias
#StepWhat you actually doTools you will use
1Goal & hypothesesState the question in plain words, then as H₀ and H₁. Pick α up front.a sentence, not code
2Data typesLabel every variable continuous, ordinal, or nominal. This alone rules most tests in or out.df.dtypes, judgment
3DescribeCounts, means, medians, spread, group sizes. Meet the dataset before touching it.describe(), value_counts()
4VisualizeHistograms, boxplots, violins, bars, scatter, Q-Q. See the shape, the groups, the outliers.matplotlib, seaborn
5Clean & prepareHandle missing values, duplicates, impossible entries, and outliers. Transform if needed.pandas, np.log
6DesignOne sample, independent groups, paired, factorial, or repeated? Name the structure.a diagram, a sentence
7Check assumptionsNormality (Shapiro-Wilk, K-S, Q-Q) and equal variance (Levene, Bartlett). Report each.scipy.stats, pingouin
8Decide & fixAssumptions hold, use the parametric test. They fail, transform or switch to a rank-based test.the fork in Section 3
9Choose the testData type, groups, and design point to exactly one test (with its nonparametric twin).the map in Section 4
10Run & reportCompute the statistic, the p-value, the effect size, and the interval. Post-hoc if needed.scipy, statsmodels
11InterpretAnswer the original question in plain language. Separate statistical from practical significance.plain English
12Ethics & biasWho was sampled, what could bias it, how far does the conclusion generalize, what is the risk of misuse?honest reflection
2

It All Starts With the Data Type

Before any test, ask what kind of number you have. This single question, from Levels of Measurement, does most of the work of choosing a test, because each data type admits a different family of methods.

Data typeWhat it isExamplesTypical methods
ContinuousNumbers you can average; equal intervals, a true or arbitrary zero.weight, blood pressure, time, scoret-tests, ANOVA, Pearson correlation
OrdinalOrdered categories without equal spacing; ranks and Likert scales.satisfaction 1–7, pain 0–10, rankingsrank-based tests, Spearman, Kendall
NominalUnordered categories; labels and counts.region, commute mode, pass/failchi-square, proportion tests
The one habit that prevents most mistakes

Treating an ordinal scale as if it were continuous is the most common error in applied statistics. Averaging a 1-to-5 satisfaction score is tempting, but the gap from "poor" to "fair" need not equal the gap from "good" to "excellent." When a variable is ordinal or clearly non-normal, the rank-based tests (Capstones 14–16) are the honest choice, and this framework tells you exactly when to reach for them.

3

Assumptions Come First, Then the Test

The parametric tests, t-tests, ANOVA, and Pearson correlation, earn their power by assuming things about the data: roughly normal distributions and, when comparing groups, roughly equal variances. The discipline of every capstone is to check those assumptions before choosing the test, not after. If they hold, use the parametric test. If they fail, transform the data or switch to the rank-based twin, which makes no such assumption.

AssumptionHow to check itWhat the test says
NormalityShapiro-Wilk (best for small n), Kolmogorov-Smirnov, and a Q-Q plot by eyea small p-value means "not normal"; trust the plot as much as the p
Equal varianceLevene's test (robust, preferred) or Bartlett's test (assumes normality)a small p-value means the groups' spreads differ
Independencefrom the study design, not a test: were observations gathered separately?if paired or repeated, use the matched-design test
Enough dataexpected counts ≥ ~5 (chi-square); ~10 successes and failures (proportions)if too sparse, use an exact test
Check first, then choose: the assumptions fork THE CHECKS Shapiro-Wilk Kolmogorov-Smirnov Levene's test Bartlett's test + a Q-Q plot Do they hold? step 7 → step 8 HOLD Parametric test t-test · ANOVA · Pearson r VIOLATED Transform, or go rank-based Mann-Whitney · Kruskal-Wallis Wilcoxon · Spearman

Notice the order. The assumption tests do not choose the test for you; they tell you which version of the test is trustworthy. A skewed outcome with heavy outliers is not a reason to abandon the analysis, it is a signal to reach for the rank-based twin, which answers the same question without the normality assumption.

4

Choosing the Test

With the data type known and the assumptions checked, the test almost picks itself. Answer three questions, is the outcome numeric or categorical, how many groups, and are they independent or matched, and the map below lands you on a single method, with its rank-based fallback in parentheses for when the assumptions do not hold.

Outcome type? numeric categorical / rate 1 vs valueone-sample t(Wilcoxon) 2 pairedpaired t(Wilcoxon SR) 2 indep.two-sample t(Mann-Whitney) 3+ groupsANOVA(Kruskal-Wallis) 2 variablesPearson r(Spearman/tau) a ratez for proportions(exact binomial) 2 variableschi-square(Fisher exact) Goodness-of-fit compares one categorical variable to an expected distribution (Capstone 9). Parentheses show the rank-based or exact fallback when assumptions fail.
QuestionDesignParametric testIf assumptions failEffect size
Mean vs a targetone sampleone-sample t-testWilcoxon signed-rankCohen's d
Two groups differ?independenttwo-sample (Welch) t-testMann-Whitney UCohen's d, rank-biserial
Change within subjectspairedpaired t-testWilcoxon signed-rankCohen's dz
3+ groups differ?independentone-way ANOVA + TukeyKruskal-Wallis + Dunnη², ε²
3+ conditions, same subjectsrepeatedrepeated-measures ANOVAFriedmanpartial η²
Two factors + interactionfactorialtwo-way ANOVA(align-and-rank / robust)partial η²
Two categories associated?chi-square of independenceFisher's exactCramer's V
Fits an expected split?chi-square goodness-of-fitexact multinomialCramer's V, w
A rate vs a target / anotherone- / two-proportion z-testexact binomialrisk difference, h
Two numeric variables move together?Pearson correlationSpearman ρ / Kendall τr itself, r²
5

Report Honestly, and Fairly

A test that stops at "p < 0.05" is only a third of an answer. With a big enough sample almost anything is "significant," and with too small a sample a real effect hides. Every capstone closes the same way: three numbers together, then a plain-language verdict, then a look at what could make it wrong.

Always reportThe question it answers
p-valueCould chance alone produce a result this extreme? (yes/no at α)
Effect sizeHow big is the effect? (Cohen's d, η², Cramer's V, r) — the part that actually matters
Confidence intervalHow precisely do we know it? A range, not a single point

Then the twelfth step: ethics and bias. Every dataset was collected by someone, from someone, for some purpose, and those choices shape what the numbers can honestly say. A convenience sample does not represent a population. A survey question can lead its respondent. A significant result on a biased sample is a confident wrong answer. Two of the capstones ahead are built on real survey data precisely so we can walk through the questionnaire and the sampling method and ask, out loud, who this conclusion is really about.

Automate the evidence, author the argument

Each capstone ships two artifacts, and the split is deliberate. A notebook does the reproducible work: it loads the data, runs the twelve steps, and produces every figure and number. A written report, authored by a statistician for a non-statistician, tells the story: what we found, what we did about the messy parts, why we chose the test we did, and what it means for the decision at hand. The computer makes the evidence; a person makes the case.

6

The Sixteen Capstones Ahead

Sixteen projects, grouped by the question they answer, each one a complete pass through the framework on its own downloadable dataset, with a full notebook and a statistician's written report. They become clickable here as each one is published; the Contents always shows what is live.

The t-Tests · comparing means
1
One-Sample t-Test
Coffee Fill Weight
Are the bags really filled to the 340 g on the label, or is quality control drifting?
2
Two-Sample t-Test
A New Onboarding Program
Does the new program get hires productive faster than the standard one?
3
Paired t-Test
Blood Pressure Before & After
Did an eight-week program lower blood pressure in the same patients?
Comparing Many Markers at Once · the multiple-comparisons trap
4
Multiple Comparisons
Screening Heart-Disease Markers
Test seven clinical markers at once, and correct for the false alarms that testing many creates.
Analysis of Variance · three or more groups
5
One-Way ANOVA
Three Teaching Methods
Do three ways of teaching produce different exam scores, and which pairs differ?
6
Repeated-Measures ANOVA
Cognitive Training Over Time
Do the same people improve across four sessions, beyond ordinary fluctuation?
7
Two-Way ANOVA
Fertilizer and Sunlight
Do two factors each matter for plant growth, and do they interact?
Categorical Data & Proportions · counts and rates
8
Chi-Square Independence
Commute Mode by Region
Is how people commute related to where they live? A survey, from questionnaire to test.
9
Chi-Square Goodness-of-Fit
Weekday Traffic
Are website visits spread evenly across the week, or is the "even" assumption wrong?
10
Proportion Tests
Email Signup Rates
Does the signup rate beat its target, and does one campaign beat another?
Correlation & Association · how two variables move together
11
Pearson Correlation
Study Hours and Scores
How strongly do hours studied track exam performance, and how sure are we?
12
Spearman Correlation
Satisfaction and Loyalty
Do two Likert survey scales rise together when the relationship is not a straight line?
13
Kendall's Tau
Two Judges' Rankings
How much do two judges agree when ranking twelve products, ties and all?
When Assumptions Fail · the rank-based tests
14
Mann-Whitney U
Two Pain Treatments
With skewed, ordinal pain scores, which treatment relieves more, without assuming normality?
15
Wilcoxon Signed-Rank
Service Ratings Before & After
Did paired, ordinal service ratings improve when their differences are not normal?
16
Kruskal-Wallis
Ratings Across Four Stores
Do four locations differ on skewed rating scales, and which ones stand apart?

🎓 Key Takeaways

  • One framework, twelve steps: frame the question, explore and prepare the data, validate and choose, then test and conclude. Every capstone follows it.
  • Data type first: continuous, ordinal, or nominal decides the family of tests before anything else.
  • Check assumptions, then choose: Shapiro-Wilk and K-S for normality, Levene and Bartlett for equal variance, and switch to a rank-based test when they fail.
  • Three questions pick the test: outcome type, number of groups, and independent vs matched, each with a nonparametric twin.
  • Finish honestly: a p-value, an effect size, and an interval together, plus a candid look at sampling, bias, and generalizability.
7

Quiz: Test Yourself

Eight quick questions on the framework the whole part is built on. Answer them, hit Check Answers, and keep refining until you score 100%. Your progress is saved, so you can hop back to the chapter and return anytime.