About this project
How the lab was rebuilt
MAST90138 Multivariate Statistics for Data Science at The University of Melbourne, 2023 Semester 2. Two individual assignments by Sunchuangyu (Rin) Huang, originally written in R Markdown, revived in 2026 as a static, client-side web app.
Timeline
When the work was done
11 September 2023
Assignment 1 submitted: covariance, eigen-decomposition and PCA of the wheat data
Between A1 and A3
Assignment 2 (not preserved, so not part of this lab)
22 October 2023
Assignment 3 submitted: high-dimensional classification of rainfall stations
2026
Revived as Multivariate Lab: original R re-run, algorithms ported, bugs documented
Method
Ported, tested, and only then made pretty
Each module below is a TypeScript port of the R function the assignment used, with a Vitest parity test against numbers produced by R from the original code. Your browser recomputes the wheat PCA, the logistic fits, the LOOCV curve, the test-set classification and the PLS tree. The rainfall PCA and PLS scores, the correlation curves and the random forests (22 forests of 5,000 trees, original seed) are computed in R and shipped as small JSON files; the kernel PLS port is checked against them in the test suite.
| Module | Port of | Checked against R |
|---|---|---|
| lib/linalg.ts | Cyclic Jacobi eigen-decomposition, covariance, standardisation | eigen(cov(X)) for the wheat data to 1e-10; prcomp eigenvalues of the 365 × 365 rainfall correlation matrix to 1e-8 |
| lib/eigen2.ts | Closed-form 2 × 2 eigen-decomposition, covariance validity, ellipse geometry | R's eigen() for the Problem 1(b) matrix |
| lib/pca.ts · lib/seeds.ts | PCA (covariance / correlation), ψ, scores, correlation circle, the as-submitted projection | prcomp(X, scale = TRUE) loadings and the 2023 report's printed values (signs included) |
| lib/glm.ts | glm.fit IRLS for binomial(logit) with LINPACK dqrdc2/dqrsl pivoting QR and R's link clamping | glm(G ~ PC1 + PC2 + PC3) coefficients, deviance and iteration count |
| lib/loocv.ts | Hand-written LOOCV for q = 1..30, corrected and bug-for-bug as submitted; test classification | all 30 LOOCV counts for both versions and the test errors for every q |
| lib/pls.ts | pls::kernelpls.fit for one response; projection of new stations (test suite only: the site uses the PLS scores exported by R) | plsr scores and projection matrix (relative error below 1e-6), including head(pls_data) from the 2023 PDF |
| lib/rpart.ts | rpart classification trees: Gini splits, minsplit/minbucket, cp complexity bookkeeping | the identical tree (C1 < 1.563, C2 < −9.094) and test predictions |
Errata
What was wrong in the 2023 submissions
The originals are left untouched; each lab shows the submitted and the corrected behaviour side by side.
A1 Problem 1(a)
Symmetry was ignored, giving b ≥ 3a. A covariance matrix must be symmetric (a = 3) and PSD (b ≥ 9).
See it in the labA1 Problem 2
Covariance PCA was asked, correlation PCA was run, and the scatter projected raw, uncentred X onto standardised loadings.
See it in the labA3 Question 2
See it in the labpredict()found noX_traincolumn and returned training fits, so LOOCV picked q = 27 by accident; test stations were not standardised and log-odds were cut at 0.5. Corrected: q = 3, 1 test error.A3 Question 3(1)
See it in the labif (oob_error <- min_oob_error)assigned instead of compared, so mOOB was always 8c ≈ 152.8398. Corrected: m = 57; the test error stays at 3. (The 4-decimal grid was harmless: randomForest rounds m itself.)A3 Question 3(3)
Test stations were centred but not divided by the training SDs before the PLS projection: 16 errors. Standardised properly, the same tree makes 1.
See it in the lab
Data and integrity
Provenance and academic integrity
Data
The wheat measurements are the public UCI “seeds” dataset (Charytanowicz et al., 2010, CC BY 4.0) and are bundled with the app. The rainfall curves were supplied with the course; the site only serves class-level daily summaries, principal component and PLS projections, importances and error counts derived from them by scripts/a3_artefacts.R.
Academic integrity
This is my own submitted work, published after the subject finished. The original R Markdown, knitted reports and figures are preserved unchanged in the repository's coursework/ folder. The assignment specifications are not reproduced; the tasks are paraphrased. Please do not submit any of it as your own.
The repository (github.com/rNLKJA/Unimelb-Master-2023-MAST90138-Assignments) is private for now. It holds the original submissions in coursework/ and the R scripts that generate this site's data in scripts/.