Statistics Coursework Sample: Hypothesis Tests and Regression on Real Data, Every Step Shown
A statistics coursework example on open UCI data about 649 students at two Portuguese secondary schools in 2005 to 2006. It runs a Welch t-test, a one-way ANOVA with Tukey HSD, a chi-square test and a multiple regression with diagnostics. Each test comes with its R command and Excel route, and the findings are written up with their limits.
This is a statistics coursework sample we built on an open dataset, not a student's submitted work, so nothing is hidden: the research question, the hypotheses, a Welch t-test, a one-way ANOVA with Tukey HSD, a chi-square test and a multiple regression with its diagnostics, then the findings written with their limits. The data is the UCI Student Performance file of 649 secondary-school records (Cortez, 2008), and every figure comes from the scripts you can download near the end.
What Does This Statistics Coursework Sample Cover?
It answers one research question on 649 Portuguese secondary-school students surveyed in 2005 to 2006 (Cortez and Silva, 2008): does weekly study time predict the final grade once past failures, absences, home background and school are held constant? The one-way ANOVA and the regression answer it. The t-test and the chi-square test are run on two of the model's controls, because a methods brief sets one of each.
From the brief to the findings paragraph
- State the research question One question the data can answer: does weekly study time predict the final grade once past failures, absences, home background and school are held constant?
- Name the variables and their types Final grade is numeric on a 0 to 20 scale; study time is an ordinal band; school, sex, internet and higher-education intention are binary; failures is a small count and mother's education an ordered level from 0 to 4.
- Choose the test A t-test for two groups, a one-way ANOVA for four, a chi-square test for two categorical variables and a multiple regression for several predictors at once.
- Check the assumption Levene's test and a normality check before the t-test and the ANOVA, expected counts before the chi-square, and residual plots, Shapiro-Wilk, Breusch-Pagan, RESET and VIF after the regression.
- Run it in R or Excel One command in R for each test; the Analysis ToolPak or a worksheet function in Excel, with the gaps in Excel stated.
- Report it in the standard form Statistic, degrees of freedom, p-value, the effect size and a confidence interval, in one sentence a findings section can use.
- Interpret it and state the limit Answer the question in words, then say what the design cannot support: the data is observational, from two schools, in one school year.
Each test is run the way an examiner expects: hypotheses before the test, the assumption checked before the result is read, the statistic with an effect size and a confidence interval, and the interpretation stopped where the design stops. More samples in this subject are in our maths and science assignment samples, and our science and maths assignment help page explains how we take a brief with a dataset attached.
Which Dataset Does the Sample Use, and Why?
It uses the Student Performance dataset in the UCI Machine Learning Repository (id 320), licensed CC BY 4.0, and its Portuguese-language file, student-por.csv: 649 students from two public schools in Portugal's Alentejo region, 33 columns, no missing values, collected in the 2005 to 2006 school year from school reports and a classroom questionnaire (Cortez and Silva, 2008).
The Portuguese-language file at a glance
- Final grades of exactly zero
- 15 2.3 percent of students; only two others score below 6, so the zeros stand apart and drive the failed normality check later.
- Mean final grade
- 11.91/20 Median 12, standard deviation 3.23; the most common grade is 11.
- Zero-grade students who also record zero absences
- 15 of 15 And 14 of the 15 are at the MS school; the file does not say why.
- Correlation of the second period grade with the final grade
- 0.92 Which is why G1 and G2 stay out of the model; the leakage section shows what happens if they go in.
Grades run from 0 to 20 over three evaluation periods, with the third as the final grade. At 649 rows the file opens in Excel as easily as in R, and it carries two features that test whether the analyst looked before running anything: a small spike of final grades at exactly zero, and two earlier period grades that would make any regression look brilliant and mean nothing.
| Variable | Role | Values | In the file (n = 649) |
|---|---|---|---|
| G3 | Outcome: final grade | 0 to 20 | Mean 11.91, SD 3.23, median 12, range 0 to 19; 15 students at exactly 0 (2.3%) |
| studytime | Predictor of interest | Four bands: 1 under 2 h, 2 from 2 to 5 h, 3 from 5 to 10 h, 4 over 10 h a week | 212 / 305 / 97 / 35 |
| failures | Control: past class failures | 0 to 3 (3 is the top code in the file) | 549 / 70 / 16 / 14 |
| absences | Control: school absences | 0 to 32 in this file | Mean 3.66, median 2; 37.6% have none |
| higher | Control: wants higher education | yes / no | 580 / 69 |
| internet | Grouping variable for the t-test | yes / no | 498 / 151 |
| school | Control, and one side of the chi-square | GP (Gabriel Pereira) / MS (Mousinho da Silveira) | 423 / 226 |
| sex | Control | F / M | 383 / 266 |
| Medu | Control: mother's education | 0 none; 1 primary (4th grade); 2 5th to 9th grade; 3 secondary; 4 higher | 6 / 143 / 186 / 139 / 175 |
| G1, G2 | Period grades, used only in the leakage check | 0 to 20 | Means 11.40 and 11.57 |
The most common final grade is 11 (104 students), the distribution is close to symmetric between 7 and 18, and then 15 students sit at zero with almost nothing between zero and 5. The file does not say why, and neither does the paper, but the file can be looked at: all 15 record zero absences, 14 of the 15 are at MS, and 7 already scored zero in the second period, a pattern that fits students who stopped attending, which the file does not confirm. The coursework carries the zeros through every test and, in the regression, reports what happens with and without them. Our data mining dissertation sample takes the same reproducible-script approach on a much larger UCI file.
How Do You Write the Hypotheses for a Statistics Coursework?
Write a null hypothesis of no difference or no association, a two-sided alternative, and fix the significance level at 0.05 before you look at any output. For this coursework that gives three null hypotheses: the mean final grade is the same with and without home internet; the four study-time bands share one mean; school and higher-education intention are independent.
- Test 1, two groups: H0, mu_yes = mu_no; H1, the two means differ.
- Test 2, four groups: H0, mu_1 = mu_2 = mu_3 = mu_4; H1, at least two band means differ, the form Illowsky and Dean (2023, section 13.1) use.
- Test 3, two categorical variables: H0, school and intention to take higher education are independent; H1, they are not.
- The model: for each coefficient, H0, it is zero once the other six predictors are in; H1, it is not.
Every test is two-sided, because nothing in the brief said which direction to expect. A one-sided test is legitimate only when the direction is written down before the data is seen; used after the fact it halves the p-value for free, and an examiner marks it down. Alpha is fixed in advance for the same reason: choosing it after seeing p = 0.06 is not a decision rule.
A p-value below 0.05 says that, if the null hypothesis were true, a result at least this extreme would be unusual. It does not say the effect is large, useful or causal, and it does not say the alternative is 95 percent likely. That is why every test below carries an effect size (Cohen's d, eta squared, Cramér's V, or the coefficient itself) and a confidence interval beside the p-value. Definitions follow Illowsky and Dean (2023) and Navarro (2026), sections listed under Sources. For the same discipline on one probability question, see our probability and statistics assignment sample.
Do Students With Internet at Home Score Higher? A Two-Sample t-Test
Yes, on average: 12.17 with internet at home against 11.03 without, a difference of 1.15 points, Welch t(229.4) = 3.66, p < 0.001, 95 percent CI 0.53 to 1.76, Cohen's d 0.36. Levene's test did not detect unequal variances (p = 0.763), and the pooled t-test agrees, t(647) = 3.86. It is a difference between groups, not an effect of having internet.
The Student t-test assumes the two groups share one variance; Welch drops that assumption and keeps normality and independence (Navarro, 2026, section 13.4). Its degrees of freedom come from the two sample variances and sizes, which is why the df is 229.4 and not a whole number. Levene's test is reported first (W = 0.09, p = 0.763), centred on the median, the car::leveneTest default that makes it the Brown-Forsythe variant (Fox, Weisberg and Price, 2026). The zero grades make both groups non-normal (Shapiro-Wilk p < 0.001 in each), but with 151 and 498 students the t-test rests on the sample means, and a Mann-Whitney test gives the same verdict (U = 45,616, p < 0.001).
Cohen's d is the difference between the means divided by the pooled standard deviation: 1.146 over the pooled SD gives d = 0.359, approximate 95 percent interval 0.175 to 0.542. Against the benchmarks of 0.2, 0.5 and 0.8, that is small to medium, about a third of a standard deviation. A findings section reports it like this:
Students with internet access at home scored higher in the final Portuguese grade (M = 12.17, SD = 3.12, n = 498) than students without it (M = 11.03, SD = 3.45, n = 151). Levene's test did not indicate unequal variances (W = 0.09, p = 0.763). A Welch two-sample t-test found the difference significant, t(229.4) = 3.66, p < 0.001, mean difference 1.15 grade points, 95% CI [0.53, 1.76], Cohen's d = 0.36.
Internet access is not in the research question, so it is not in the model, and the model shows why that is safe: with the seven predictors held constant, the internet gap falls to 0.351 points (p = 0.192) and the study-time coefficient is unchanged at 0.438. Most of the raw gap is the other things the two groups differ on.
In R: leveneTest(G3 ~ internet, data = d) from the car package, then t.test(G3 ~ internet, data = d), which runs Welch unless you add var.equal = TRUE. R orders the groups alphabetically and subtracts yes from no, so it prints t = -3.66 and a negative interval; the size and the p-value are the same. In Excel: Data, Data Analysis, "t-Test: Two-Sample Assuming Unequal Variances", or =T.TEST(range_yes, range_no, 2, 3) for the p-value alone, 2 for two-tailed and 3 for unequal variances (Microsoft, n.d.b). The tool rounds the Welch degrees of freedom to the nearest integer to read its critical value, so it shows 229, while T.TEST uses the unrounded figure (Microsoft, n.d.a).
Do Students Who Study More Score Higher? A One-Way ANOVA
Yes, on average, up to the third band. Mean final grade climbs from 10.84 under 2 hours a week through 12.09 and 13.23, then flattens at 13.06 over 10 hours: F(3, 645) = 15.88, p < 0.001, eta squared 0.069. Tukey HSD puts the lowest band below the other three and band 2 below band 3; between the top two there is no detectable difference.
Mean final grade by weekly study-time band
Chart data
| Item | Value (/20) |
|---|---|
| Under 2 h (n=212) | 10.84/20 |
| 2 to 5 h (n=305) | 12.09/20 |
| 5 to 10 h (n=97) | 13.23/20 |
| Over 10 h (n=35) | 13.06/20 |
One-way ANOVA assumes normal populations, independent samples and equal variances. The group standard deviations run from 2.50 to 3.24 and Levene's test does not reject equal variances (W = 1.03, p = 0.380); had it rejected, the fallback is the Welch one-way test (Navarro, 2026, section 14.8), which gives F(3, 139.1) = 18.18, the same verdict. The zero grades break normality, and the rank-based Kruskal-Wallis test agrees with the F-test, H(3) = 50.32, p < 0.001. The groups are unbalanced (212, 305, 97 and 35 students): R's TukeyHSD adjusts for unequal sizes and is documented for mildly unbalanced designs (R Core Team, 2026); with the largest band nine times the smallest, read the intervals involving the over-10-hours band as approximate.
| Source | Sum of squares | df | Mean square | F | p |
|---|---|---|---|---|---|
| Between bands | 465.08 | 3 | 155.03 | 15.88 | < 0.001 |
| Within bands (residual) | 6,298.19 | 645 | 9.76 | ||
| Total | 6,763.27 | 648 |
F is the mean square between groups over the mean square within, and under the null hypothesis it should be approximately one; 15.88 is nowhere near that. Eta squared is the between-groups sum of squares over the total, 465.08 over 6,763.27, or 0.069: study-time band accounts for 6.9 percent of the variation in final grade. Quote it beside the F, because the F says only that the bands differ, not by how much.
| Comparison | Mean difference | 95% CI | Adjusted p | Detectable difference? |
|---|---|---|---|---|
| Band 2 vs band 1 | 1.25 | 0.53 to 1.97 | < 0.001 | Yes |
| Band 3 vs band 1 | 2.38 | 1.40 to 3.37 | < 0.001 | Yes |
| Band 4 vs band 1 | 2.21 | 0.74 to 3.68 | < 0.001 | Yes |
| Band 3 vs band 2 | 1.14 | 0.20 to 2.07 | 0.010 | Yes |
| Band 4 vs band 2 | 0.97 | -0.47 to 2.40 | 0.308 | No |
| Band 4 vs band 3 | -0.17 | -1.76 to 1.42 | 0.993 | No |
Six pairwise t-tests at 0.05 each would raise the chance of at least one false positive; Tukey's procedure holds the family-wise error rate at 0.05 across all six (R Core Team, 2026). The step from under 2 hours to 2 to 5 hours is worth about 1.25 grade points and the step to 5 to 10 hours another 1.14; beyond 10 hours the data detect no further gain, though that band has only 35 students and a wide interval. The bands are ordinal categories, treated as categories here and as a 1 to 4 scale in the regression, a choice the diagnostics section tests.
In R: fit_aov <- aov(G3 ~ factor(studytime), data = d), summary(fit_aov), TukeyHSD(fit_aov), and eta squared from the sums of squares in the summary. In Excel: four columns, one per band, then Data Analysis, "Anova: Single Factor" (Microsoft, n.d.a). Excel has no Tukey tool. Six T.TEST calls at alpha 0.05/6 (0.0083) is a Bonferroni correction, not Tukey; say so in the write-up.
Do the Two Schools Differ in Who Plans to Go to University? A Chi-Square Test
Yes. At Gabriel Pereira 7.6 percent of students did not intend to take higher education; at Mousinho da Silveira 16.4 percent did not, more than double. The chi-square test of independence gives chi-square(1) = 11.115 with the Yates correction, p < 0.001, Cramér's V = 0.136, a weak association. Every expected count is above 5; the smallest is 24.03.
| School | Higher education: no | Higher education: yes | Total |
|---|---|---|---|
| GP, observed | 32 (7.6%) | 391 (92.4%) | 423 |
| GP, expected | 44.97 | 378.03 | 423 |
| MS, observed | 37 (16.4%) | 189 (83.6%) | 226 |
| MS, expected | 24.03 | 201.97 | 226 |
| Total | 69 | 580 | 649 |
Each expected count is the row total times the column total over the grand total: for MS students not intending higher education, 226 times 69 over 649, or 24.03, against 37 observed. The test is trustworthy only when every expected count is at least 5 (Illowsky and Dean, 2023, section 11.3), which four cells of 649 students clear easily. Degrees of freedom are (rows minus 1) times (columns minus 1), so 1.
Two statistics, both correct. R's chisq.test applies the Yates continuity correction to a 2 by 2 table by default, subtracting one half from each absolute difference between observed and expected (R Core Team, 2026), because counts are whole numbers while the chi-square distribution is continuous (Navarro, 2026, section 12.3); that gives 11.115. Excel's CHISQ.TEST uses the plain Pearson formula (Microsoft, n.d.c) and gives 12.024. State which you used; we report the corrected value as the headline with the uncorrected one beside it. Cramér's V is the square root of chi-square over n times (k minus 1), k being the smaller of the row and column counts (Navarro, 2026, section 12.4). We take the uncorrected statistic, the square root of 12.024 over 649, which is 0.136. Either is acceptable once stated. Values near 0 mean no association; 0.136 is weak but clearly not zero.
School and higher-education intention are both controls in the regression. They are associated, but at V = 0.136 far from collinear, and the variance inflation factors in the diagnostics (at most 1.18) confirm that both can stay in.
In R: tab <- table(d$school, d$higher), chisq.test(tab) for the corrected version, chisq.test(tab, correct = FALSE) to match Excel, and chisq.test(tab)$expected for the expected counts. In Excel: build the 2 by 2 observed table with COUNTIFS, build the expected table from the marginals with the formula above, then =CHISQ.TEST(observed_range, expected_range), which returns the p-value only (Microsoft, n.d.c); the statistic itself is one more cell, the sum of (observed minus expected) squared over expected.
What Does the Regression Show Once the Other Predictors Are Held Constant?
Study time still predicts the grade, at less than half its raw slope. On its own, each study-time band is worth 0.973 grade points (95 percent CI 0.682 to 1.264); with the other six predictors held constant it is worth 0.437 (CI 0.168 to 0.707, p = 0.002). Past failures, higher-education intention and school carry larger coefficients, and the model's adjusted R squared is 0.284.
Regression coefficients for the final grade, each with the other six held constant
Chart data
| Item | Value ( grade points) |
|---|---|
| Wants higher education (yes vs no) | 1.71 grade points |
| One more study-time band (per band) | 0.44 grade points |
| Mother's education (per step, 0 to 4) | 0.31 grade points |
| One more absence (per absence) | -0.04 grade points |
| Male vs female | -0.69 grade points |
| School MS vs GP | -1.4 grade points |
| Past failures (per failure, linear estimate) | -1.47 grade points |
The model was fixed before the output was seen: G3 on studytime (as a 1 to 4 scale), failures, absences, higher (1 if yes), school (1 if MS), sex (1 if male) and Medu (0 to 4), chosen from the research question and the paper's attribute list. The period grades G1 and G2 were excluded on purpose; the section after next shows why. Choosing predictors after seeing which come out significant is a weaker procedure, and a coursework that does it should say so.
| Predictor | Coefficient | SE | t | p | 95% CI |
|---|---|---|---|---|---|
| Intercept | 9.998 | 0.535 | 18.70 | < 0.001 | 8.948 to 11.048 |
| studytime (per band) | 0.437 | 0.137 | 3.18 | 0.002 | 0.168 to 0.707 |
| failures (per failure, linear) | -1.469 | 0.194 | -7.58 | < 0.001 | -1.850 to -1.089 |
| absences (per absence) | -0.038 | 0.024 | -1.57 | 0.116 | -0.085 to 0.009 |
| higher = yes | 1.711 | 0.378 | 4.52 | < 0.001 | 0.968 to 2.453 |
| school = MS | -1.397 | 0.241 | -5.79 | < 0.001 | -1.871 to -0.923 |
| sex = M | -0.691 | 0.227 | -3.04 | 0.002 | -1.137 to -0.245 |
| Medu (per step) | 0.306 | 0.101 | 3.03 | 0.003 | 0.107 to 0.504 |
R squared 0.291, adjusted R squared 0.284, F(7, 641) = 37.65, p < 0.001, residual standard error 2.73 grade points.
Holding the other six constant, students one band higher in weekly study time have final grades 0.437 points higher on average, and the interval says the true value is plausibly anywhere from 0.17 to 0.71. Against the unadjusted slope of 0.973, more than half of the raw association is shared with the other six predictors: students who study more also differ in failures, school and background, and the regression separates those. The ceiling on the wording is "students who study more have higher grades, holding the rest constant"; "studying more raises grades" is a causal claim that a cross-sectional questionnaire cannot support.
Past failures has the largest t statistic (minus 7.58), and the pre-specified estimate is 1.469 points lower per failure. The diagnostics section shows that this average misdescribes the shape: the drop comes with the first failure, about 2.8 points, and a second or third adds little. Either way it fits the paper's finding that past failures matter most when no period grades are available (Cortez and Silva, 2008). Wanting higher education goes with 1.711 more points, a large gap for a yes-or-no variable, though it may be as much a record of existing attainment as a cause of it. Absences are not significant at 5 percent (p = 0.116); one of the re-runs below changes that.
The seven predictors account for 28.4 percent of the variation in final grade and leave 71.6 percent unexplained; the residual standard error of 2.73 says a typical prediction misses by nearly three points on a 20-point scale. Background variables were never going to explain most of a grade; report that as a limit. Adjusted R squared is quoted because it rises only when an added predictor improves the fit by more than chance would (Navarro, 2026, section 15.4.3).
In R: fit <- lm(G3 ~ studytime + failures + absences + higher + school + sex + Medu, data = d), then summary(fit) and confint(fit); R builds the 0/1 dummies itself, with no, GP and F as the baselines, so its rows read higheryes, schoolMS and sexM. In Excel: build three 0/1 columns with IF, copy the seven X columns side by side because the Regression dialog takes one X range, then Data Analysis, "Regression" with G3 as the Y range (Microsoft, n.d.a). LINEST returns the same block as an array, with the coefficients in reverse column order (Microsoft, n.d.d).
Do the Regression Assumptions Hold, and What Happens If They Do Not?
Not fully. The residuals are not normal (Shapiro-Wilk p < 0.001) and their spread is not constant (Breusch-Pagan LM = 39.17, p < 0.001), mostly because of the 15 zero grades, yet with HC3 standard errors study time stays significant (p = 0.001). A RESET test finds curvature (p = 0.012), and re-coding past failures removes it. The VIF and Cook's distance checks pass.
R's plot(fit) draws residuals against fitted values, a normal Q-Q plot, a scale-location plot and a leverage plot. The residuals run from minus 12.41 to plus 7.43 with skewness of minus 0.89, and 12 standardised residuals fall below minus 3 while none rise above plus 3; 11 of the 12 are zero grades. They sit on a diagonal line of their own in the first plot, because a student who scored zero has a residual of exactly minus their predicted grade, and they are the left tail dropping away from the line in the Q-Q plot. No curve is obvious by eye, but the RESET test, which adds the squared and cubed fitted values to the model, rejects a straight-line fit, F(2, 639) = 4.44, p = 0.012.
| Check (what it tests) | Result | Verdict | What it changes |
|---|---|---|---|
| Shapiro-Wilk (normal residuals) | W = 0.942, p < 0.001 | Fails | Intervals rely on normality only loosely at n = 649; the zeros are most of the cause, so re-run 2 removes them. |
| Breusch-Pagan, Koenker studentised (constant variance) | LM = 39.17, p < 0.001 | Fails | Conventional standard errors may be wrong; re-run 1 replaces them with HC3. |
| Ramsey RESET (linearity) | F(2, 639) = 4.44, p = 0.012 | Fails | The count coding of past failures accounts for it; re-run 3 codes it as categories and RESET passes (p = 0.277). |
| Variance inflation factors (collinearity) | 1.08 to 1.18; largest is higher at 1.18 | Passes | Nothing; the predictors are nearly independent of one another. |
| Cook's distance (influence) | Largest 0.0315; 33 above 4/n (0.0062); none above 1 | Passes | Nothing; no single student moves the coefficients. |
Navarro (2026, section 15.8) lists what a linear regression needs: normal residuals, a linear relationship, constant variance and independent residuals, plus uncorrelated predictors and no bad outliers. Breusch-Pagan here is the studentised form R's bptest runs by default, and RESET asks whether powers of the fitted values explain anything a straight line missed (Hothorn et al., 2022). The square root of a VIF says how much wider a coefficient's interval is than with uncorrelated predictors (Fox, Weisberg and Price, 2026). For Cook's distance, Navarro (2026, section 15.9.2) treats a value above 1 as large and 4 over n as a rule of thumb: 33 students pass 4 over n, none nears 1, and the largest is a student with 30 absences and a grade of 16, unusual but plausible, so nothing is removed.
Which term bends the line can be tested. The obvious suspect was study time, forced onto four equal steps when the ANOVA showed the top band flattening. Entered as four categories instead, RESET is unchanged (F(2, 637) = 4.35, p = 0.013), and the data do not reject equal steps (F(2, 639) = 0.70, p = 0.50). Entering past failures as categories removes the curvature (RESET F(2, 637) = 1.29, p = 0.28), and the count coding is rejected (F(2, 639) = 8.89, p < 0.001). The raw means say why: 12.51 with no failures, then 8.64, 8.81 and 8.07. The whole drop comes with the first failure (adjusted, minus 2.764, 95 percent CI minus 3.479 to minus 2.049); a second or third adds almost nothing, and study time barely moves, at 0.423 (CI 0.156 to 0.690, p = 0.002). That is re-run 3 in Table 7. The primary model stays as pre-specified; the re-coding is a sensitivity check prompted by the diagnostic, and the write-up says so.
| Predictor | Original (n = 649) | Re-run 1: HC3 standard errors (n = 649) | Re-run 2: without the 15 zero grades (n = 634) | Re-run 3: failures as categories (n = 649) |
|---|---|---|---|---|
| studytime | 0.437, p = 0.002, CI 0.168 to 0.707 | 0.437, p = 0.001, CI 0.189 to 0.686 | 0.348, p = 0.002, CI 0.124 to 0.573 | 0.423, p = 0.002, CI 0.156 to 0.690 |
| failures | -1.469 per failure, p < 0.001 | -1.469, p < 0.001 | -1.204, p < 0.001 | One: -2.764; two: -2.612; three: -3.093 (each p < 0.001) |
| absences | -0.038, p = 0.116 | -0.038, p = 0.128 | -0.078, p < 0.001 | -0.026, p = 0.285 |
| higher = yes | 1.711, p < 0.001 | 1.711, p < 0.001 | 1.486, p < 0.001 | 1.650, p < 0.001 |
| school = MS | -1.397, p < 0.001 | -1.397, p < 0.001 | -0.838, p < 0.001 | -1.273, p < 0.001 |
| sex = M | -0.691, p = 0.002 | -0.691, p = 0.003 | -0.609, p = 0.001 | -0.720, p = 0.001 |
| Medu | 0.306, p = 0.003 | 0.306, p = 0.006 | 0.383, p < 0.001 | 0.274, p = 0.006 |
| Adjusted R squared; residual SE | 0.284; 2.73 | 0.284; 2.73 | 0.292; 2.26 | 0.301; 2.70 |
| RESET | F(2, 639) = 4.44, p = 0.012 | Unchanged | F(2, 624) = 9.09, p < 0.001 | F(2, 637) = 1.29, p = 0.277 |
HC3 standard errors leave every estimate where it was and change no verdict: study time moves from p = 0.002 to p = 0.001 and absences stays non-significant. HC3 is the default in R's sandwich package, on the strength of a simulation study its documentation cites (Zeileis and Lumley, 2026). It corrects the standard errors for non-constant variance and nothing else; the non-normal residuals, the zero-grade cluster and the curvature stay exactly as they were.
Dropping the 15 zero grades changes the sample, and because the rows are chosen by their outcome it changes the question, to students who received a non-zero grade: a sensitivity check, not a corrected estimate. Study time falls to 0.348 and stays significant. The school gap shrinks from 1.397 to 0.838 because 14 of the 15 zero-grade students are at MS. Absences become clearly significant at minus 0.078 per absence, because all 15 record no absences and were pulling the slope the other way. Skewness falls from minus 0.89 to 0.15, yet Shapiro-Wilk (W = 0.987, p < 0.001) and Breusch-Pagan (LM = 14.95, p = 0.037) still reject, and RESET rejects more strongly (p < 0.001): the zeros were most of the normality problem and none of the curvature. A coursework reports all three re-runs with the reason for each. For a contrast, our agile project management dissertation sample reports a regression from SPSS output, with the diagnostics read from the software's tables.
Why Must the Period Grades Stay Out of This Model?
Because they are the same outcome measured earlier. The second period grade correlates with the final grade at r = 0.919 and the first at 0.826. Adding both lifts adjusted R squared from 0.284 to 0.850 and pushes every other coefficient towards zero: study time falls from 0.437 to 0.061 (p = 0.336), past failures from -1.469 to -0.201, and absences, sex and mother's education lose significance. The full table is in the output files.
The same model without and with the period grades G1 and G2
| Point of comparison | Without G1, G2 | With G1, G2 |
|---|---|---|
| Adjusted R squared | Without G1, G2 0.284 | With G1, G2 0.850 |
| studytime (per band) | Without G1, G2 0.437 (0.002) | With G1, G2 0.061 (0.336) |
| failures (per failure) | Without G1, G2 -1.469 (< 0.001) | With G1, G2 -0.201 (0.030) |
| higher = yes | Without G1, G2 1.711 (< 0.001) | With G1, G2 0.168 (0.342) |
| school = MS | Without G1, G2 -1.397 (< 0.001) | With G1, G2 -0.205 (0.072) |
| G1 and G2 | Without G1, G2 excluded | With G1, G2 0.129 (< 0.001) and 0.883 (< 0.001) |
A model that predicts a grade from itself answers nothing the brief asked, and this dataset sets that trap. Cortez and Silva (2008) tested three input setups, with both period grades, without G2, and without either, and reported that "a good predictive accuracy can be achieved, provided that the first and/or second school period grades are available". For their purpose, predicting a student's final result from what a school already knows during the year, G2 is a legitimate input. For this coursework's question, whether study habits and background explain achievement, it is what machine learning calls leakage: G2 is the same subject's grade from the previous period, and a model saying study time, failures and mother's education no longer matter has not found that they do not matter. It has found that they already acted on G2. For this question an examiner treats it as a method error, and it is easy to recognise: an R squared far above what background variables reach, and a predictor that is a version of the outcome.
The rule to write down: when the question is what explains an outcome, do not adjust for an earlier measurement of that outcome, or for anything the explanatory variables act through, unless the question is deliberately about progress and says so. When the task is prediction during the year, as in Cortez and Silva (2008), the period grades are legitimate inputs. Past failures sits near the same line, which is why the limits below read its coefficient as prior attainment.
How Would a Marker Read These Results?
As an answer to the question, with the limits attached. The strong paragraph below leads with the test, the statistic, the effect size and the direction, then says what the data cannot support. Marks are lost on choosing the wrong test, skipping the assumption check, reading p as importance and claiming cause from a questionnaire, not on the arithmetic.
A weak answer against a strong answer, on the same output
| Point of comparison | Weak answer | Strong answer |
|---|---|---|
| Stating the hypothesis | Weak answer "We tested whether study time affects grades." | Strong answer H0: the four study-time bands share one mean final grade; H1: at least two band means differ. Two-sided, alpha 0.05, fixed before the output. |
| Reporting the test | Weak answer "The ANOVA was significant (p < 0.05)." | Strong answer F(3, 645) = 15.88, p < 0.001, eta squared 0.069; Tukey HSD: band 1 below every other band, band 2 below band 3, no detectable difference between bands 3 and 4. |
| Handling a failed assumption | Weak answer Not mentioned, or the failing test deleted. | Strong answer Breusch-Pagan rejects, so HC3 standard errors; Shapiro-Wilk rejects because of 15 zero grades, so a re-run without them; RESET rejects, so failures is re-coded; all three re-runs reported. |
| Interpreting a coefficient | Weak answer "Studying more raises grades by 0.437." | Strong answer Each step up a study-time band is associated with 0.437 more grade points (95 percent CI 0.168 to 0.707), holding failures, absences, school, sex, mother's education and intention constant. |
| Stating the limits | Weak answer "Further research is needed." | Strong answer Observational data from two schools in one region in 2005 to 2006; study time self-reported in bands; 71.6 percent of variance unexplained; no causal claim. |
First, the paragraph a first-year often writes on this output:
The ANOVA was significant (p < 0.05), showing that studying more improves grades. The regression fitted well (R squared 0.29) and every variable was significant except absences, so study time, failures, school, sex, mother's education and wanting higher education all affect the final grade.
It loses four marks in two sentences: "p < 0.05" with no statistic, effect size or interval; "improves" and "affect", causal verbs on questionnaire data; "fitted well" for a model that leaves 71.6 percent unexplained; and significance read as importance. No assumption check appears anywhere. The same output, written for the marks:
Weekly study time was associated with the final Portuguese grade in 649 students from two schools. A one-way ANOVA found a significant difference across the four study-time bands, F(3, 645) = 15.88, p < 0.001, eta squared = 0.069; Tukey HSD placed students studying under 2 hours a week 1.25 to 2.38 points below every other band, with no detectable difference between the two highest bands. In a multiple regression controlling for past failures, absences, school, sex, mother's education and intention to take higher education, each higher study-time band was associated with 0.437 more grade points (95% CI [0.168, 0.707], p = 0.002), less than half the unadjusted slope of 0.973; past failures (b = -1.469) and intention to take higher education (b = 1.711) carried the largest unstandardised coefficients, and the model explained 28.4% of the variance (adjusted R squared = 0.284). Residuals were non-normal and heteroscedastic, largely because of 15 zero grades, and a RESET test indicated curvature traced to the count coding of past failures; HC3 standard errors, a re-run without the zero-grade students (b = 0.348) and a re-run with failures as categories (b = 0.423) all left the study-time association significant at p = 0.002 or below. Two secondary tests on the model's controls: students with internet at home scored 1.15 points higher, Welch t(229.4) = 3.66, p < 0.001, d = 0.36, a gap that fell to 0.35 (p = 0.192) inside the model; and MS students were less likely to intend higher education, chi-square(1) = 11.115, p < 0.001, V = 0.136.
The limits, stated in the coursework:
- The data is observational. Every association above is compatible with reverse or shared causes: students who already do well may study more, and the family background that shapes study time also shapes grades. No result here licenses "studying more raises grades".
- Two public schools in one Portuguese region in the 2005 to 2006 school year (Cortez and Silva, 2008). The coefficients describe that cohort, not a UK university or 2026.
- Study time is self-reported in four bands. The regression treats them as a 1 to 4 scale, so "0.437 per band" assumes equal steps; the data do not reject that (p = 0.50), though the top band rests on 35 students. The coding that does not hold is past failures as a count: the drop comes with the first failure.
- Fifteen students have a final grade of exactly zero, all with no recorded absences, for reasons the file does not record. They break the normality and constant-variance assumptions, and re-runs 1 and 2 are reported because of them.
- The model explains 28.4 percent of the variance. Most of what decides a final grade is not in these seven variables.
- Intention to take higher education and past failures are as much records of prior attainment as influences on it, so their coefficients should not be read as effects of choice.
If this analysis were a dissertation findings chapter, the same paragraph would sit under a results heading with the diagnostics in an appendix; our thesis and dissertation help page covers that format. If your brief is the study design, the business research methods sample shows how a quantitative design is justified, and the fishbone diagram example carries control charts on quality data.
How Do You Reproduce This Analysis in R and in Excel?
In R, after read.csv, the four tests are t.test, aov with TukeyHSD, chisq.test and lm, plus three packages for the checks: car, lmtest and sandwich. In Excel, three Analysis ToolPak tools (t-Test, Anova and Regression) and the T.TEST and CHISQ.TEST functions cover the four tests; the checks are built by hand or recorded as a limit.
Four files sit behind every figure on this page: the Python script that computed the published numbers (pandas, SciPy and statsmodels; Virtanen et al., 2020; Seabold and Perktold, 2010) and its output, and the R script with the commands on this page and its output. The R script was run in R 4.5.3 with car, lmtest and sandwich, and the two outputs agree at every figure the page prints. Run either against the UCI file and compare your numbers with ours.
| Step | R | Excel |
|---|---|---|
| Read the semicolon file | d <- read.csv("student-por.csv", sep = ";") | Data, From Text/CSV with the semicolon delimiter. |
| Levene's test | leveneTest(G3 ~ internet, data = d) | Not in the ToolPak. Put each student's absolute deviation from their group's median in a new column, then run Anova: Single Factor on it by group; its F is the Levene (Brown-Forsythe) statistic. |
| Cohen's d | Three lines: the pooled SD from the two variances and counts, then the mean difference over it. | One cell: the mean difference over the pooled SD built from VAR.S and the two counts. |
| Diagnostics | plot(fit); shapiro.test(residuals(fit)); bptest(fit); resettest(fit); vif(fit); cooks.distance(fit) | Tick Residuals in the Regression dialog: the output lists predicted Y and residuals, and a scatter chart of one against the other is the residuals-against-fitted plot. The dialog's Residual Plots are residuals against each predictor. No Shapiro-Wilk, Breusch-Pagan, RESET, VIF or Cook's distance tool. |
| HC3 standard errors | coeftest(fit, vcov = vcovHC(fit, type = "HC3")); coefci with the same vcov for the intervals | Not available. |
A coursework written in Excel should say in one sentence that the Tukey, Levene, Breusch-Pagan, RESET, VIF and Cook's distance steps were not available in the software and were either built by hand or omitted, and what that means for the conclusions. That sentence earns credit. If your module allows it, run the diagnostics in R on the same file and cite both tools. The natural next exercise is the Mathematics file, student-mat.csv, in the same download: 395 students and a larger share of zero grades.
If you have a statistics coursework or data analysis to do on your own dataset, send the brief, the data file and the deadline on WhatsApp. We will tell you what we can do, from choosing the tests to writing the findings with their limits, and our science and maths assignment help page explains how the work is handled.
Sources
- Cortez, P. (2008) Student Performance [Dataset]. UCI Machine Learning Repository, id 320, donated November 2014, licence CC BY 4.0. doi:10.24432/C5TG7T. UCI Machine Learning Repository (accessed 24 September 2026). Source of student-por.csv, the file every figure on this page is computed from, and of the variable codes in Table 1.
- Cortez, P. and Silva, A. (2008) 'Using data mining to predict secondary school student performance', in Brito, A. and Teixeira, J. (eds) Proceedings of 5th Annual Future Business Technology Conference, Porto, 2008. EUROSIS, pp. 5-12. ISBN 978-9077381-39-7. University of Minho repository (accessed 24 September 2026). Source for the collection (two public schools in the Alentejo, the 2005 to 2006 school year, the 0 to 20 scale over three periods), the three input setups and the finding that past failures matter most when no period grades are available.
- Illowsky, B. and Dean, S. (2023) Introductory Statistics 2e. Houston, Texas: OpenStax. Sections 10.1 (the Aspin-Welch t-test, Cohen's d and its benchmarks), 11.3 (expected counts and the rule of five), 13.1 (the assumptions of one-way ANOVA) and 13.2 (the F ratio). OpenStax (accessed 24 September 2026).
- Navarro, D. (2026) Learning Statistics with R, version 0.7.0, online edition, CC BY-SA 4.0. Sections 12.3 to 12.5 (the continuity correction, Cramér's V, the chi-square assumptions), 13.4 (the Welch test), 13.9.2 (Shapiro-Wilk), 14.4 (eta squared), 14.7 and 14.8 (Levene's test and the Welch one-way test), 15.4.3 (adjusted R squared), 15.8 (what a regression needs), 15.9.2 (Cook's distance) and 15.9.6 (VIF). learningstatisticswithr.com (accessed 24 September 2026).
- R Core Team (2026) The R Stats Package, version 4.6.1, reference manual: t.test (Welch by default), aov, TukeyHSD (family-wise coverage and the adjustment for mildly unbalanced designs), chisq.test (the continuity correction on 2 by 2 tables) and lm (accessed 24 September 2026). The published R output was produced with R 4.5.3, which gives the same figures.
- Fox, J., Weisberg, S. and Price, B. (2026) car: Companion to Applied Regression, R package version 3.1-5, CRAN (accessed 24 September 2026): leveneTest (median centre by default) and vif.
- Hothorn, T., Zeileis, A., Farebrother, R.W. and Cummins, C. (2022) lmtest: Testing Linear Regression Models, R package version 0.9-40, CRAN: bptest (Koenker's studentised statistic by default) and resettest (squared and cubed fitted values by default) (accessed 24 September 2026).
- Zeileis, A. and Lumley, T. (2026) sandwich: Robust Covariance Matrix Estimators, R package version 3.1-3, CRAN (accessed 24 September 2026): vcovHC, with HC3 as the default following Long and Ervin's simulation study of 2000.
- Seabold, S. and Perktold, J. (2010) 'statsmodels: econometric and statistical modeling with Python', Proceedings of the 9th Python in Science Conference. Cited as the project asks at statsmodels.org (accessed 25 September 2026); version 0.15.0 computed the regression, the diagnostics, the Tukey comparisons and the re-runs on this page.
- Virtanen, P., Gommers, R., Oliphant, T.E. et al. (2020) 'SciPy 1.0: fundamental algorithms for scientific computing in Python', Nature Methods, 17(3), pp. 261-272. doi:10.1038/s41592-019-0686-2. Cited as the project asks at scipy.org (accessed 25 September 2026); version 1.18.1 computed the t-tests, Levene's tests, the chi-square, Shapiro-Wilk, Mann-Whitney and Kruskal-Wallis figures on this page.
- Microsoft (n.d.a) Use the Analysis ToolPak to perform complex data analysis. Microsoft Support: the Anova: Single Factor, Regression and t-Test: Two-Sample Assuming Unequal Variances tools, the rounding of the Welch df to the nearest integer and the unrounded df in T.TEST. support.microsoft.com (accessed 24 September 2026).
- Microsoft (n.d.b) T.TEST function. Microsoft Support: the tails and type arguments. support.microsoft.com (accessed 24 September 2026).
- Microsoft (n.d.c) CHISQ.TEST function. Microsoft Support: the expected range built from row and column totals, the formula for the statistic and the degrees of freedom. support.microsoft.com (accessed 24 September 2026).
- Microsoft (n.d.d) LINEST function. Microsoft Support: the returned array {mn, mn-1, ..., m1, b}, which lists the coefficients in reverse column order. support.microsoft.com (accessed 25 September 2026).
Frequently Asked Questions
What is a good example of a statistics coursework?
One that states a research question, names the dataset, chooses each test for a reason and checks its assumption first, reports the statistic with an effect size and a confidence interval, and ends with what the data cannot support. This sample does that on 649 open student records, and the findings paragraph near the end shows how the results are written up.
When do I use ANOVA instead of a t-test?
Use a t-test, in its Welch form unless you have a reason to pool the variances, to compare the means of two groups. Use a one-way ANOVA when the grouping variable has three or more levels, because a t-test on every pair inflates the chance of a false positive; if the F-test is significant, Tukey HSD shows which pairs differ. The internet-access and study-time sections work one of each.
What does a p-value of 0.002 mean in a regression?
It means that, if the true coefficient were zero, an estimate at least this far from zero would turn up about twice in a thousand samples. That is evidence against zero; it is not the probability that the coefficient is zero, and it says nothing about how large or important the effect is. For size, read the coefficient and its interval: the regression section reports study time at 0.437 grade points per band, 95 percent CI 0.168 to 0.707.
Can I use Excel for a statistics coursework, or do I need R or SPSS?
Excel's Analysis ToolPak runs the t-test, the one-way ANOVA and the regression, and T.TEST and CHISQ.TEST return the p-values. It has no Tukey HSD, Levene, Breusch-Pagan, VIF or Cook's distance tool, so you build those by hand or state the gap as a limit. R covers every step in a few lines; the reproduction section lists both routes side by side.
Do you help with statistics coursework on my own dataset?
Yes. Send the brief, the data file and the deadline on WhatsApp and we will tell you what we can do: choosing and justifying the tests, running them in R, Excel or the tool your module names, and writing the findings and limits in the form shown on this page. Our science and maths assignment help page describes how the work is handled.