Skip to content
Statistics LabMAST20005 · 2020

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.

  1. 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 against

    D = 0.142

    p = 0.2960 ± 0.014

    999 Monte Carlo draws, seed 11

  2. 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 against

    W = 0.830

    p = 0.0091

  3. 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 against

    W = 0.912

    p = 0.2945

  4. 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 against

    W = 0.919

    p = 0.4248

  5. 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 against

    F = 15.280

    p = 0.0016

  6. 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 against

    W = 0.986

    p = 0.9883

  7. 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 against

    BP = 0.289

    p = 0.5908

  8. 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 against

    DW = 2.178

    p = 0.6722 ± 0.010

    2,000 Monte Carlo draws, seed 3

  9. 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 against

    max |t| = 2.446

    p = 0.5123

  10. 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 against

    runs = 4

    p = 0.0020

  11. A3 Q1

    Victorian daily cases

    n = 21

    No serial correlation

    Ljung–Box, lags 1–7

    Lag-1 autocorrelation is 0.63.

    strong evidence against

    Q = 25.834

    p = 0.0005

  12. 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 against

    Kendall τ = -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 εi∼N(0,σ2)\varepsilon_i\sim N(0,\sigma^2), 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 nR2nR^2 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
Figure C.1.Residuals in the order the rows were entered. Long runs above or below zero would point to serial correlation, which the Durbin–Watson test measures.
Show the numbers as a table
Residuals in order
rowresidual
1-1.16
2-103.22
366.39
4-21.43
564.64
69.47
713.33
8-23.57
9-71.14
1087.67
1179.83
12-55.24
13-16.40
148.42
15-30.54
16-5.38
1714.74
187.74
1911.12
20-35.26
  • Externally studentised residual
  • Bonferroni 5% cut-off
Figure C.2.Each residual is studentised with its own row left out of σ̂, so it follows a t distribution with n − 3 degrees of freedom. The dashed lines are where a single point would be an outlier after allowing for 20 looks (±3.54).

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, D=sup⁡x ∣Fn(x)−(1−e−x/xˉ)∣D=\sup_x\,|F_n(x)-(1-e^{-x/\bar x})|. 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
Figure C.3.Exponential QQ plot with the scale removed: ordered values divided by their mean against Exp(1) quantiles at R’s plotting positions. The band shows where 95% of samples of size 30 from a true exponential fall at each position. 1 of 30 points lie outside it. A pointwise band is expected to miss about 2 of 30 by chance, so a few points outside is not evidence on its own.
Show the numbers as a table
QQ points and envelope
Exp(1) quantilex / x̄2.5%97.5%
0.0170.0010.0010.117
0.0510.0710.0090.181
0.0870.1040.0260.229
0.1240.1390.0460.273
0.1630.1410.0720.323
0.2030.2140.0950.376
0.2440.2170.1190.429
0.2880.2260.1530.481
0.3330.2660.1880.536
0.3810.3430.2160.606
0.4310.4410.2530.661
0.4830.4490.2880.735
0.5390.4780.3330.795
0.5980.5760.3800.863
0.6600.5900.4320.926
0.7270.6690.4820.991
0.7990.6850.5461.075
0.8750.9750.5961.170
0.9591.0070.6801.252
1.0501.0510.7521.375
1.1501.1450.8291.478
1.2611.1480.9361.609
1.3861.2031.0531.771
1.5291.2511.1611.959
1.6961.2841.3162.184
1.8971.7731.4682.450
2.1482.0101.6342.841
2.4852.1021.8353.354
2.9964.1342.1814.242
4.0945.3062.5546.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
Figure C.4.4 runs above and below the median, where a random ordering would give about 11.0. Values of the same kind cluster together in time, so the days do not behave like exchangeable draws from one distribution.
Show the numbers as a table
The series
dayvaluevs median
7 Sep48above
8 Sep70above
9 Sep47above
10 Sep40above
11 Sep35above
12 Sep41above
13 Sep30above
14 Sep39above
15 Sep41above
16 Sep25below
17 Sep44above
18 Sep20below
19 Sep13below
20 Sep11below
21 Sep28equal
22 Sep14below
23 Sep11below
24 Sep13below
25 Sep12below
26 Sep16below
27 Sep5below
  • Sample autocorrelation
  • ±1.96/√n
Figure C.5.Autocorrelation at lags 1 to 7. Bars beyond the dashed lines are larger than independent values would usually give (the band is approximate and pointwise).

Explain this resultoptional · your own key

Add your own Anthropic or OpenAI key in AI settings to enable. Nothing is sent without one.