One Question, an ANOVA and a Regression
Many intermediate statistics courses end with the same group project. Four of you collect your own data on one question and analyze it twice: first as a one-way ANOVA across at least three conditions, then as a multiple regression with control variables. Then you hand in a paper. Each stage has its own lesson on this site, and this guide goes through the whole project once. It uses commute-mood.csv from the practice datasets, so you can reproduce every number from the file you download. At step 7 the two analyses have to be reconciled, and one of the group differences shrinks by nearly half.
Step 1 · A question your design can actually answer
A project question has to meet two requirements before anyone collects data. It needs a predictor with three or more levels, because a two-level predictor gives you a t-test and the assignment asks for an ANOVA. And it needs an outcome measured on a continuous scale, because both analyses assume one. From Question to Hypothesis shows how to turn a vague interest into something testable, and Variables & Operationalization covers deciding what you will measure.
The question used in this guide: does how students travel to campus relate to how they feel when they arrive? The predictor is commute mode with three levels (walking or cycling, public transport, car). The outcome is a mood rating taken on arrival, on a 0 to 100 slider.
The harder part comes next. Students were not randomly assigned to a commute mode, so any difference you find has an obvious alternative explanation, and a reviewer will point it out. People who live near campus walk. People who live far away do not. If distance also affects mood, then comparing the three modes partly compares how far people live from campus, and the group means alone cannot separate the two. A variable like distance is a confounder. It is why the assignment asks for a regression as well as an ANOVA: the regression lets you hold it constant.
Two controls were chosen before any data existed, for two different reasons:
- Distance from campus in kilometers, because it plausibly causes both the predictor and the outcome. Where you live is decided before you pick a commute mode, so distance comes before mode in the causal chain, not after it. Controlling for a variable that comes after your predictor answers a different question, and Multiple Regression explains why.
- Hours slept the night before, because it plausibly affects mood without having much to do with commute mode. A control like this makes the estimates more precise without correcting any bias, as step 7 shows.
Write both controls into the proposal, each with its reason. A control chosen after the analysis looks like a search for a significant result, and Questionable Research Practices explains why reviewers treat it that way. Preregistration & Open Science shows how to make the commitment public.
Step 2 · Collecting it, and the sample size that decides everything
This is a short campus survey. Over two weeks, four fieldworkers stop students as they arrive and ask for their commute mode, distance and sleep, plus a mood rating. Designing Surveys & Questionnaires covers the wording. Sampling Methods covers the part that limits your conclusions: the students who walk past your table at 9 a.m. are not a random sample of any population.
One design decision determines the analysis and cannot be changed later. Each person contributes one row and appears in only one condition, so this is a between-subjects design and needs a between-subjects ANOVA. If you had followed the same people across modes, you would need Repeated Measures ANOVA instead, with a different error term. Read Between vs Within Designs (about ten minutes) before you print the questionnaire.
Then the sample size, from the power calculator. For a one-way ANOVA with k = 3 groups, a medium effect (f = .25), α = .05 and 80% power, you need N = 158, about 53 per group. The study in this file collected 150, 50 per group, which is slightly short. At that size the design has 78% power for a medium effect, and the smallest effect it detects with 80% power is f = .26. Report this in one sentence in the method section and one in the limitations. Do not compute power from the effect you observed: that is a transformation of your own p-value and adds no information.
Step 3 · The codebook, then the cleaning
Write the codebook before the first row arrives. It is a page that says what every column is called, what type it is, which values are allowed and what a blank cell means. With it, someone can open your file next year and understand it. Codebooks & Documentation explains more. Here is the full codebook for this file:
| Variable | Type | Values |
|---|---|---|
participant_id | ID | 1–150, one row per person, no reuse |
mode | nominal, 3 levels | walk_cycle · public_transport · car |
distance_km | continuous | home to campus, one decimal, 0.3–17.8 observed |
sleep_hours | continuous | previous night, one decimal, 4.7–9.3 observed |
mood | continuous | arrival mood slider, integer 0–100, 44–87 observed |
Writing the codebook first gives the cleaning something to check against. Run the four passes The Cleaning Workflow sets out: structure (150 rows, five columns, one row per person), completeness (no blank cells), validity (every mode is one of the three legal strings, every number inside its declared range, participant_id unique), and consistency. This file passes all four because it was built for teaching, and real fieldwork data rarely does. Data Entry & Validation shows what a real intake sheet looks like, and messy-clinic.csv in the same dataset library is a file with the errors left in.
Never edit the raw file. Keep the original untouched and make every correction in a script or a syntax file, so anyone can see each step from what you collected to what you analyzed. Reproducible Workflows covers this. A script also settles the matter when two group members report different means.
Step 4 · Look at the data before you test anything
Start with descriptives by condition, because an ANOVA table means little without them. Paste a column into the descriptives calculator and it returns the mean, the sample SD, the quartiles, a t-based interval and the outlier flags:
| Mode | n | Mood M (SD) | Distance M (SD) | Sleep M (SD) |
|---|---|---|---|---|
| Walk or cycle | 50 | 73.26 (7.84) | 2.09 (0.78) | 6.88 (0.93) |
| Public transport | 50 | 64.14 (7.98) | 7.44 (2.87) | 6.89 (0.88) |
| Car | 50 | 64.56 (7.07) | 9.80 (3.38) | 7.03 (0.84) |
Read the covariate columns as carefully as the outcome column, because they are the reason for the second analysis. Walkers live 2.09 km from campus on average and drivers 9.80 km, a gap of nearly eight kilometers, so the groups differ a lot on distance. Sleep, by contrast, is almost the same in all three (6.88, 6.89, 7.03). From these two facts, predict what each control will do to the group differences, then check your prediction at step 7.
The whole-sample outcome is roughly symmetric: M = 67.32, SD = 8.68, Mdn = 68, and an adjusted Fisher–Pearson skewness of 0.01. One value is flagged by the 1.5 × IQR rule: participant 81's mood of 44, just under the lower fence of 45.5. Outliers: Detect, Investigate, Decide is clear that the next step is to investigate, not to delete. Check the row against the codebook: 44 is an allowed mood value, the person's distance and sleep are both ordinary, and nothing suggests a typing error. Keep it, and check later whether it changed anything. It did not. At step 6 the model puts its residual 2.5 standard errors below zero, which is not unusual in 150 cases, and its Cook's distance is 0.03, far below the threshold of 1.
Step 5 · The one-way ANOVA
Two assumptions determine whether the ordinary F is the right test, and ANOVA & t-Test Assumptions covers both. Independence comes from the design: one row per person, no clustering, each person surveyed once. Equal variances is tested: Levene's test on the three mood distributions gives F(2, 147) = 0.51, p = .604. The group variances are 61.5, 63.6 and 49.9, a largest-to-smallest ratio of 1.28, so pooling the variances is justified and the ordinary F is appropriate. If Levene's test had been significant, you would use Welch's ANOVA, which the same lesson covers.
SPSS prints the table under Analyze → Compare Means → One-Way ANOVA. The arithmetic behind every cell is explained in the One-Way ANOVA lesson, whose Build the ANOVA Table widget works through it cell by cell on your own numbers.
SPSS · ANOVA · dependent variable: mood
| Sum of Squares | df | Mean Square | F | Sig. | |
|---|---|---|---|---|---|
| Between Groups | 2650.680 | 2 | 1325.340 | 22.707 | <.001 |
| Within Groups | 8579.960 | 147 | 58.367 | ||
| Total | 11230.640 | 149 |
η² is not in this table. Compute it yourself: 2650.680 / 11230.640 = .236.
Read it left to right. The two sums of squares add up exactly to the total, and the whole method rests on that partition. Each mean square is a sum of squares divided by its degrees of freedom. The within-groups mean square, 58.367, is the pooled variance. Its square root, 7.64, is the pooled standard deviation sp, which every follow-up test below uses. F is the ratio of the two mean squares, 1325.340 / 58.367 = 22.71, against a critical F*(2, 147) of 3.06 from the printed tables. And η² = .236 says commute mode accounts for about 24% of the variance in arrival mood, with a 90% confidence interval of [.14, .32].
The omnibus test says only that the three means are not all equal. The question named a specific comparison in advance, so the follow-up should be a planned contrast and not a search through all three pairs. Active travel against the average of the two motorized modes has coefficients [1, −½, −½], and Post-Hoc Tests lets you build it interactively:
ψ̂ = 8.91, SE = 1.32, t(147) = 6.73, p < .001, 95% CI [6.30, 11.53]. Active commuters arrive about nine mood points above the motorized average, and the interval is far from zero. Written as whole numbers, [2, −1, −1], the estimate doubles to 17.82 and so does its standard error, so t does not change. That gives you a quick check that you built the contrast correctly.
The three pairwise comparisons, Bonferroni-corrected against a critical t** of 2.42, give the same result in more detail. Walking is 9.12 points above public transport and 8.70 above car, both with adjusted p < .001. Public transport and car differ by 0.42 points, adjusted p = 1.000. So the three modes form two groups: walking or cycling, and the two motorized modes together.
Step 6 · The same question, asked as a regression
A regression needs numbers, and mode is a word. Dummy coding converts it: pick one level as the reference, then make one 0/1 column for each of the others. With public transport as the reference you get walk_cycle (1 if they walked, else 0) and car. Use two columns for three groups, never three, because a third would be perfectly predictable from the other two and the model could not be estimated. Categorical Predictors & Dummy Coding covers this, and SPSS does it for you under Transform → Recode into Different Variables or through the Automatic Linear Modeling dialog.
Fit the dummies on their own first. It takes one line in the write-up, and every later comparison refers back to it.
SPSS · Coefficients · model 1: dummies only
| Model | B | Std. Error | t | Sig. |
|---|---|---|---|---|
| (Constant) | 64.140 | 1.080 | 59.365 | <.001 |
| walk_cycle | 9.120 | 1.528 | 5.969 | <.001 |
| car | 0.420 | 1.528 | 0.275 | .784 |
R² = .236 · adjusted R² = .226 · SE of the estimate = 7.640 · F(2, 147) = 22.707, p < .001
Every one of those numbers is already on this page. The constant, 64.140, is the mean of the reference group. The walk coefficient, 9.120, is exactly 73.26 − 64.14, and the car coefficient is 64.56 − 64.14. R² equals η² to fifteen decimal places, and the model F is the ANOVA's F. There is no new analysis here, only the same one in regression notation, and Inference for Regression explains the correspondence.
Now add the controls. This is the model the assignment asks for.
SPSS · Coefficients · model 2: + distance_km + sleep_hours
| Model | B | Std. Error | t | Sig. | 95% CI | VIF |
|---|---|---|---|---|---|---|
| (Constant) | 46.132 | 4.700 | 9.815 | <.001 | [36.84, 55.42] | — |
| walk_cycle | 5.092 | 1.793 | 2.841 | .005 | [1.55, 8.64] | 2.299 |
| car | 1.704 | 1.460 | 1.167 | .245 | [−1.18, 4.59] | 1.524 |
| distance_km | −0.756 | 0.217 | −3.479 | <.001 | [−1.19, −0.33] | 2.583 |
| sleep_hours | 3.432 | 0.638 | 5.378 | <.001 | [2.17, 4.69] | 1.009 |
R² = .398 · adjusted R² = .382 · SE of the estimate = 6.826 · F(4, 145) = 24.001, p < .001
Read each coefficient with the phrase that makes it correct. Holding distance and sleep constant, active commuters arrive 5.09 points above transport users. Holding everything else constant, each additional kilometer from campus is associated with 0.76 fewer mood points, and each additional hour of sleep with 3.43 more. Leave the phrase out and you claim something the model does not support, because the phrase is part of what a partial coefficient means.
Run three diagnostics before you trust any of it, all from Regression Diagnostics and Assumptions of Regression. The residual plot (tick Save → Unstandardized residuals in SPSS, then plot them against the fitted values) should be a band with no pattern, and this one is. The correlation between absolute residual and fitted value is −.02, so the spread does not grow with the fitted values. The residuals are close to normal, with a skewness of −0.15 and an excess kurtosis of −0.28. No case has leverage over the 3p/n threshold of 0.10, and no Cook's distance is anywhere near 1 (the largest is 0.05). VIF is the last column of the table above, and Multicollinearity & Variable Selection explains how to read it. A VIF of 2.58 on distance means its standard error is √2.58 = 1.6 times what it would be if distance were unrelated to the other predictors. That increase comes from controlling for a variable correlated with your predictor. Here it is modest, and every VIF is well under the conventional threshold of 5.
Step 7 · Making the two analyses agree
In the paper you have to explain why the same comparison is 9.12 points in one table and 5.09 in another. Both numbers are correct, and they answer different questions.
The 9.12 is the raw difference between two groups of students. The 5.09 is the difference that remains when you compare people who live equally far from campus and slept equally long. The gap between the two numbers is not error. It is omitted-variable bias, and Multiple Regression gives its exact size with an identity that holds in your sample, not only on average:
braw = bcontrolled + bcontrol × δ
δ is the difference between the groups on the control variable itself, which you get by regressing the control on the same dummies. Walkers live 5.35 km closer to campus than transport users (δ = −5.35) and sleep essentially the same amount (δ = −0.004). Put the numbers in:
5.092 + (−0.756 × −5.348) + (3.432 × −0.004) = 9.120
That is the raw coefficient to the last decimal the table prints, and to fourteen decimals in the file. So distance accounts for about 4.04 points of the raw 9.12-point advantage of walking. Sleep changes it by only 0.01, as you could have predicted at step 4, where sleep was almost the same in all three groups. A control that is balanced across the groups barely shifts a group coefficient. Sleep still improved the model, because it explains variance in mood: together with distance, it lowered the residual standard error from 7.64 to 6.83 and raised R² from .236 to .398.
The car coefficient moves in the opposite direction. Raw, drivers were 0.42 points above transport users. Controlled, they are 1.70 above. Drivers live furthest from campus, so the raw comparison understated their mood relative to transport users. Neither version is statistically significant. Report both and say which one your conclusion rests on.
There is one limit on all of this. Holding a confounder constant is not the same as randomizing, and no regression can control for a variable you did not measure. You can claim that the mode difference is not only a distance difference. You cannot claim that commuting by bicycle causes better moods. Observational Designs and Quasi-Experiments & Natural Experiments explain which causal claims each kind of study supports.
Step 8 · The paper
The paper has four sections, in the order The IMRaD Structure sets out, and the results section is the only one this guide can write for you. Order it this way: descriptives, then the omnibus test, then the follow-ups, then the effect sizes, with no discussion of what any of it means. From Output to Results Section covers this. The APA Results Formatter builds any of these sentences with the typography applied and recomputes the p from your statistic as a check.
Arrival mood differed across the three commute modes, F(2, 147) = 22.71, p < .001, η² = .24, 90% CI [.14, .32]. A planned contrast comparing active travel with the two motorized modes was significant, ψ̂ = 8.91, SE = 1.32, t(147) = 6.73, p < .001, 95% CI [6.30, 11.53]. Bonferroni-corrected pairwise comparisons showed that walking or cycling exceeded public transport, Mdiff = 9.12, t(147) = 5.97, p < .001, and car use, Mdiff = 8.70, t(147) = 5.69, p < .001, while public transport and car use did not differ, Mdiff = −0.42, t(147) = −0.275, p = .784.
A multiple regression predicting arrival mood from commute mode alone reproduced the ANOVA, R² = .24, F(2, 147) = 22.71, p < .001. Adding distance from campus and hours slept improved the fit, R² = .40, F(4, 145) = 24.00, p < .001, and reduced the advantage of active travel over public transport from 9.12 to 5.09 points, b = 5.09, SE = 1.79, t(145) = 2.84, p = .005, 95% CI [1.55, 8.64]. Both covariates predicted mood: each additional kilometer from campus was associated with a 0.76-point decrease, b = −0.76, SE = 0.22, t(145) = −3.48, p < .001, and each additional hour of sleep with a 3.43-point increase, b = 3.43, SE = 0.64, t(145) = 5.38, p < .001.
Reviewers notice typography. Latin statistics are italic (F, t, p, b, M, R²), Greek ones are not (η², ψ̂), and p, η² and R² take no leading zero. Below .001 you write p < .001 and never p = .000. Reporting Statistics in APA Style covers the rules, and the APA cheat sheet is a printable version to keep beside you.
Include one figure: the three group means with 95% confidence intervals on the outcome scale, because that is the paper's main comparison. Readers see the overlap between transport and car faster in the picture than in the p-value. A second panel with the controlled estimates beside the raw ones shows step 7 more clearly than three paragraphs can. Tables & Figures That Don't Lie covers the formatting rules, and the chart chooser helps if you are unsure which kind of chart to use.
Then the limitations. Three of the four were fixed before the analysis. The sample fell 8 people short of the power target. It was collected wherever the fieldworkers stood, so it represents the students who walk past a table on a weekday morning. Commute mode was not randomly assigned, so the results cannot be read causally. And mood was one slider rating at one moment, which Reliability & Validity would call a narrow measure of a broad construct. Put all four in the discussion. Discussion & Limitations explains why a specific, accurate limitations section strengthens a paper.
Then the ethics review. Students gave their commute mode, their home distance and their sleep, and together these can identify someone on a small campus. The file that leaves your laptop should hold a code, not a name, and the key linking codes to names should be stored separately and destroyed on schedule. Privacy & Confidentiality covers the principles, and Informed Consent & Ethics Committees covers the paperwork.
This guide cannot do your project for you. Every number above comes from a simulated file, published so the method could be shown from start to finish. Your course sets its own rules about what help is allowed with your own data, including help from AI tools, and you are responsible for reading and following them. Using AI Tools Ethically explains where courses usually draw the line and why.
Step 9 · What a supervisor will grade
A supervisor checks nine things, usually in this order. Many projects lose marks on the first three, which are decided before any analysis.
| Check | What good looks like |
|---|---|
| Question | One sentence, a predictor with three or more levels, a continuous outcome, and the controls named with a reason each. |
| Design | Between or within stated explicitly, sampling described accurately, the target N from a power calculation reported with the effect size it assumed. |
| Data quality | A codebook, a raw file never edited, cleaning done in a script, outliers investigated rather than deleted. |
| Assumptions | Independence argued from the design, equal variances tested, residuals plotted, VIF reported. |
| The ANOVA | The full table, η², and a planned contrast or a corrected set of pairwise comparisons, chosen in advance. |
| The regression | Dummy coding with the reference level stated, the dummies-only model shown before the controls go in, coefficients read as partial. |
| Reconciliation | The two analyses shown to agree, and the change in the coefficients explained by the covariate imbalance, not just mentioned. |
| Interpretation | Effect sizes and intervals included in the sentences, causal language matched to the design. |
| Reporting | APA 7 throughout, a figure that answers the question, limitations that name what the study cannot say. |
One last test covers all nine. Give your raw file and your written method to someone outside the group and ask whether they can reproduce your numbers. For this project the answer is yes, and you can check it now on the same CSV. Run The Final Checklist the night before submission.
Keep going
- Practice Datasets:
commute-mood.csvto redo this project yourself, with nine other files and their worked solutions. - One Study, Start to Finish: the same steps for a 2 × 2 factorial experiment rather than a survey.
- From SPSS Output to APA Results: which number on the screen belongs in which slot.
- Clean Your Survey Data: the cleaning step worked on a file that needs it.
- Choose the Right Statistics: for when your design is not three conditions and an outcome.
- Practice Problems: ANOVA tables and regression coefficients to work by hand.