Statistics Lab / Appendix
Checking the assumptions
Every method in the coursework rests on assumptions: normal errors, equal variances, independent observations, a model that fits. The 2020 answers checked most of them by eye. This appendix tests each one formally on the original inputs, then gives you the same checks to run on any data.
- 5
- checks with strong evidence against
- 0
- checks with some evidence against
- 7
- checks with no evidence against
§C.1
The 2020 inputs, checked
The assignment datasets are not served by this site, so these checks run in the test suite and only their statistics are published, the same arrangement as the parity ledger. One fixed rule reads every p-value: below 0.01 is strong evidence against the assumption, below 0.05 is some evidence, and anything else is no evidence against.
No evidence against is not evidence for. Most of these samples have between 8 and 30 values, and a test on 10 values can miss a real departure easily. The 2020 results themselves are unchanged.
A1 Q1
Plant heights
n = 30
Heights follow an exponential distribution
Kolmogorov–Smirnov distance to Exp(1/x̄), p-value by parametric bootstrap
Consistent with the 2020 reading of the QQ plot: no evidence against the exponential model, though 30 heights cannot rule out moderate departures.
- MLE θ̂ = x̄:
- 98.17
no evidence againstD = 0.142
p = 0.2960 ± 0.014
999 Monte Carlo draws, seed 11
A1 Q2
Lognormal sample (logs)
n = 15
log X is normal, so the χ² interval for λ applies
Shapiro–Wilk on log x
Strong evidence that the logs are not normal, because the sample stays skewed even on the log scale. The χ² interval for λ relies on normal logs, so its 95% is not guaranteed here. The 2020 interval is shown unchanged, and Appendix B measures it when the model does hold.
strong evidence againstW = 0.830
p = 0.0091
A2 Q2(a)
Walking times, route X
n = 10
Times are normal (t interval)
Shapiro–Wilk
With ten values the test has little power. Appendix B measures how the t interval behaves at small n when the data are not normal.
no evidence againstW = 0.912
p = 0.2945
A2 Q2(c)
Walking times, route Y
n = 8
Times are normal (pooled t interval)
Shapiro–Wilk
Eight values: no evidence against normality, which is not the same as evidence for it.
no evidence againstW = 0.919
p = 0.4248
A2 Q2(c)–(e)
Walking times, X vs Y
n = 18
Equal variances (pooled t interval)
F test for σ²X / σ²Y (run in 2020 as part (e))
The 2020 answer's own F test rejects equal variances, which undercuts the pooled interval of part (c). The Welch interval, which does not assume them, is shown beside it. Both exclude 0.
- Pooled 95% CI (2020):
- (-7.719, -2.811)
- Welch 95% CI, df 10.4:
- (-7.578, -2.952)
strong evidence againstF = 15.280
p = 0.0016
A2 Q3
Coffee sales residuals
n = 20
Errors are normal
Shapiro–Wilk on the residuals
Agrees with the 2020 reading of the normal QQ plot.
no evidence againstW = 0.986
p = 0.9883
A2 Q3
Coffee sales residuals
n = 20
Constant error variance
Studentised Breusch–Pagan
Agrees with the 2020 reading of the scale-location plot.
no evidence againstBP = 0.289
p = 0.5908
A2 Q3
Coffee sales residuals, in day order
n = 20
Errors are independent from day to day
Durbin–Watson against positive lag-1 correlation, Monte Carlo p-value
Not checked in 2020. Rows are consecutive days, so serial correlation was possible, but the Durbin–Watson statistic gives no evidence of it.
no evidence againstDW = 2.178
p = 0.6722 ± 0.010
2,000 Monte Carlo draws, seed 3
A2 Q3
Coffee sales residuals
n = 20
No single day dominates the fit
Largest externally studentised residual, Bonferroni-adjusted
Day 19 has the largest residual. After allowing for 20 looks it is not an outlier.
- unadjusted p:
- 0.0256
no evidence againstmax |t| = 2.446
p = 0.5123
A3 Q1
Victorian daily cases, 7–27 Sep 2020
n = 21
Days are a random sample (sign and Wilcoxon tests)
Runs test above/below the median (exact)
4 runs where about 11 are expected under randomness. High days come first and low days last.
strong evidence againstruns = 4
p = 0.0020
A3 Q1
Victorian daily cases
n = 21
No serial correlation
Ljung–Box, lags 1–7
Lag-1 autocorrelation is 0.63.
strong evidence againstQ = 25.834
p = 0.0005
A3 Q1
Victorian daily cases
n = 21
No trend over the 21 days
Mann–Kendall (Kendall's τ against time)
A strong downward trend. The sign test's p = 0.9608 for “median below 15” treats every day as a draw from one distribution, which these counts are not. The 2020 question flagged this, and the checks put a size on it.
- Theil–Sen slope, cases per day (95% CI):
- -2.21 (-2.90, -1.64)
strong evidence againstKendall τ = -0.686
p = 1.5e-5
Explain this resultoptional · your own key
Add your own Anthropic or OpenAI key in AI settings to enable. Nothing is sent without one.
§C.2Coursework A2 Q3
Is the regression's error model plausible?
Least-squares estimates need only a straight-line mean, but the t tests and intervals that summary(lm) prints assume , independent and with one variance. Four checks cover those assumptions, one each.
Shapiro–Wilk tests normality of the residuals. Breusch–Pagan regresses the squared residuals on x and refers to χ²₁. Durbin–Watson compares neighbouring residuals, with a p-value simulated for this design. The outlier test takes the largest externally studentised residual and allows for having looked at all n of them.
20 rows
The seed drives the 2,000 Monte Carlo draws behind the Durbin–Watson p-value. The default data are the same simulated coffee-shop days as Chapter 5, not the assignment file.
Normal errors
p = 0.5331
Shapiro–Wilk W = 0.959 · no evidence against
Constant variance
p = 0.7552
Breusch–Pagan 0.10 on 1 df · no evidence against
Independent errors
p = 0.8596
DW = 2.44, MCSE 0.008 · no evidence against
No outlier
p = 0.3798
row 2, t = -2.59, Bonferroni · no evidence against
- Residual, in row (time) order
- Zero
Show the numbers as a table
| row | residual |
|---|---|
| 1 | -1.16 |
| 2 | -103.22 |
| 3 | 66.39 |
| 4 | -21.43 |
| 5 | 64.64 |
| 6 | 9.47 |
| 7 | 13.33 |
| 8 | -23.57 |
| 9 | -71.14 |
| 10 | 87.67 |
| 11 | 79.83 |
| 12 | -55.24 |
| 13 | -16.40 |
| 14 | 8.42 |
| 15 | -30.54 |
| 16 | -5.38 |
| 17 | 14.74 |
| 18 | 7.74 |
| 19 | 11.12 |
| 20 | -35.26 |
- Externally studentised residual
- Bonferroni 5% cut-off
Explain this resultoptional · your own key
Add your own Anthropic or OpenAI key in AI settings to enable. Nothing is sent without one.
§C.3Coursework A1 Q1
Does an exponential model fit?
The 2020 answer judged the exponential model for plant heights from a QQ plot. A formal test is the Kolmogorov–Smirnov distance between the data and the fitted exponential, . Because x̄ comes from the same data, D is smaller than the textbook KS table expects, so its null distribution is simulated by a parametric bootstrap. The same resamples give a 95% envelope for the QQ plot.
30 values
Synthetic sample
Because the mean is estimated from the same data, the usual ks.test p-value would be far too large. The null distribution of D is simulated instead from 999 exponential samples, re-estimating the mean each time.
MLE of the mean
110.59
KS distance D
0.1103
largest gap to the fitted Exp(1/x̄) CDF
Bootstrap p-value
0.663
± 0.015 (MCSE), 999 resamples
Reading (fixed rule)
no evidence against
- x₍ᵢ₎ / x̄
- Pointwise 95% envelope from the bootstrap
- y = x
Show the numbers as a table
| Exp(1) quantile | x / x̄ | 2.5% | 97.5% |
|---|---|---|---|
| 0.017 | 0.001 | 0.001 | 0.117 |
| 0.051 | 0.071 | 0.009 | 0.181 |
| 0.087 | 0.104 | 0.026 | 0.229 |
| 0.124 | 0.139 | 0.046 | 0.273 |
| 0.163 | 0.141 | 0.072 | 0.323 |
| 0.203 | 0.214 | 0.095 | 0.376 |
| 0.244 | 0.217 | 0.119 | 0.429 |
| 0.288 | 0.226 | 0.153 | 0.481 |
| 0.333 | 0.266 | 0.188 | 0.536 |
| 0.381 | 0.343 | 0.216 | 0.606 |
| 0.431 | 0.441 | 0.253 | 0.661 |
| 0.483 | 0.449 | 0.288 | 0.735 |
| 0.539 | 0.478 | 0.333 | 0.795 |
| 0.598 | 0.576 | 0.380 | 0.863 |
| 0.660 | 0.590 | 0.432 | 0.926 |
| 0.727 | 0.669 | 0.482 | 0.991 |
| 0.799 | 0.685 | 0.546 | 1.075 |
| 0.875 | 0.975 | 0.596 | 1.170 |
| 0.959 | 1.007 | 0.680 | 1.252 |
| 1.050 | 1.051 | 0.752 | 1.375 |
| 1.150 | 1.145 | 0.829 | 1.478 |
| 1.261 | 1.148 | 0.936 | 1.609 |
| 1.386 | 1.203 | 1.053 | 1.771 |
| 1.529 | 1.251 | 1.161 | 1.959 |
| 1.696 | 1.284 | 1.316 | 2.184 |
| 1.897 | 1.773 | 1.468 | 2.450 |
| 2.148 | 2.010 | 1.634 | 2.841 |
| 2.485 | 2.102 | 1.835 | 3.354 |
| 2.996 | 4.134 | 2.181 | 4.242 |
| 4.094 | 5.306 | 2.554 | 6.614 |
Explain this resultoptional · your own key
Add your own Anthropic or OpenAI key in AI settings to enable. Nothing is sent without one.
§C.4Coursework A3 Q1
Were the case counts a random sample?
The sign test and the Wilcoxon test in Assignment 3 treat each day as an independent draw from one distribution. A daily series during a lockdown is unlikely to behave like that, and the question said so. Three checks put a size on it. The runs test counts how often the series crosses its median, Ljung–Box tests the first few autocorrelations together, and Mann–Kendall tests for a monotone trend, with the Theil–Sen slope as its estimate.
Victorian daily new cases, 7–27 September 2020
Try shuffling the values into a random order. The trend and the autocorrelation disappear, and with them the evidence against a random sample.
Runs about the median
4 vs 11.0
exact p = 0.0020 · strong evidence against
Ljung–Box, 7 lags
p = 0.0005
Q = 25.8, r₁ = 0.63 · strong evidence against
Mann–Kendall trend
τ = -0.69
p = 1.5e-5 · strong evidence against
Theil–Sen slope per day
-2.21
95% CI -2.90 to -1.64
- Above the median
- Below the median
- Median
- Theil–Sen trend
Show the numbers as a table
| day | value | vs median |
|---|---|---|
| 7 Sep | 48 | above |
| 8 Sep | 70 | above |
| 9 Sep | 47 | above |
| 10 Sep | 40 | above |
| 11 Sep | 35 | above |
| 12 Sep | 41 | above |
| 13 Sep | 30 | above |
| 14 Sep | 39 | above |
| 15 Sep | 41 | above |
| 16 Sep | 25 | below |
| 17 Sep | 44 | above |
| 18 Sep | 20 | below |
| 19 Sep | 13 | below |
| 20 Sep | 11 | below |
| 21 Sep | 28 | equal |
| 22 Sep | 14 | below |
| 23 Sep | 11 | below |
| 24 Sep | 13 | below |
| 25 Sep | 12 | below |
| 26 Sep | 16 | below |
| 27 Sep | 5 | below |
- Sample autocorrelation
- ±1.96/√n
Explain this resultoptional · your own key
Add your own Anthropic or OpenAI key in AI settings to enable. Nothing is sent without one.