Skip to content
CompStats PlaygroundMAST90083 · 2023 S2

MAST90083 · Computational Statistics & Data Science · University of Melbourne · 2023 Semester 2

Computational statistics, re-run in your browser.

In 2023 I answered two assignments for this subject in R Markdown. They covered ridge versus lasso on baseball salaries, choosing the order of an autoregressive model, support vector machines and the bootstrap. This site ports that code to TypeScript line by line. You can drag λ, rerun a Monte Carlo study or retrain an SVM, and it still prints the numbers in the original PDFs.

Watch the tour: three captioned walkthroughs, about a minute each
Out [1] · glmnet(x, y, alpha = 0, lambda = 10^seq(10, -2, length = 100))
-400-2000200400-404812log λλmin = 300.9
DivisionWCRBIWalks16 other predictors
Figure 1. Ridge paths for the 19 Hitters predictors (coefficient × sd), computed at build time by the TypeScript glmnet port. Larger λ shrinks every coefficient towards zero, but none reaches it exactly.

Key results · from the 2023 submissions

What the original analysis found

Recomputed by the ports with the original seeds. The figures match the knitted R output. Where a result has sampling uncertainty, the last line adds its 2026 interval.

ridge λ chosen by 10-fold CV
300.9
test MSE 143,261 on 132 held-out players95% bootstrap interval 79,414–235,366
predictors kept by the lasso
13 / 19
at λ = 4.468; six coefficients set to exactly 0
BIC-like IC₃ finds the true AR(2)
79.8%
1,000 simulated series of length 100Wilson 95% 77.2–82.2%
overfit when n = 15
100%
every criterion picks p ≥ 7 for both models1,000 of 1,000 each; Wilson 95% 99.6–100%
test errors, tuned linear SVM
28 / 300
cost 1; the tuned radial kernel makes 319.3% error, Wilson 95% 6.5–13.2%; paired McNemar p = 0.63 against radial
bias of the plug-in , derived by hand
The submission then took the corrected estimator to be unbiased (). Revisited here: its bias is .

The brief, paraphrased

What the coursework asked

Assignment 1 · individual · R

Regularisation and model selection

  • Q1. On the ISLR Hitters data, trace ridge coefficients over 100 values of λ, explain why the ℓ₂-norm plot cannot choose λ, select λ by 10-fold cross-validation on a 131-player training split, report test error, then repeat with the lasso.
  • Q2. For AR(p) models, derive the least-squares estimator, compare three information criteria on simulated AR(5) and AR(2) data, run 1,000-replicate Monte Carlo studies at n = 100 and n = 15, and derive the probability of overfitting.

Assignment 3 · individual · R

Support vector machines and the bootstrap

  • Q1. Simulate three Gaussian classes, fit linear and radial-kernel SVMs with e1071, tune cost and γ by 10-fold CV, count support vectors and score a fresh test set.
  • Q2. For θ = (μx − μy)² with exponential samples, derive the MLEs, the bias of the plug-in estimator, its bootstrap estimate and the bias of the corrected estimator.

Assignment 2 is not part of this project because no copy of my submission survives.

Interactive notebooks

Four places to start

Method

Ported, not re-imagined

  1. 01

    Replay R's randomness

    Mersenne-Twister seeding, inversion normals and rejection sampling are ported bit for bit. set.seed(10) draws the same rows, folds and series as in 2023.

  2. 02

    Port the algorithms faithfully

    glmnet's covariance-update coordinate descent, LIBSVM's SMO solver with shrinking, cv.glmnet and e1071::tune. The submitted functions come along too, bugs included.

  3. 03

    Test against R

    An R script exports reference outputs. Vitest checks the ports against them and against the printed PDFs, from 1e-10 relative error up to exact equality of counts.

2026 upgrade: uncertainty around the results. Wilson intervals on simulated rates and error rates, paired tests wherever two methods share the same data, repeated cross-validation and coverage checks, with a model card, decision records and an optional, audit-logged AI explainer that uses your own key.Methods and decisions

About this project

MAST90083

Computational Statistics & Data Science

Institution
University of Melbourne
When
2023 Semester 2
Work
Assignments 1 and 3, individual
Author
Sunchuangyu (Rin) Huang

Original stack · 2023

R, R Markdown → PDF, glmnet, e1071, ISLR, ggplot2, MASS, tidyr

Revived stack · 2026

Next.js 16, React 19, TypeScript, Tailwind CSS 4, Web Workers, KaTeX, Vitest, and an R script for parity fixtures

The 2023 R Markdown sources and knitted PDFs are preserved unchanged in the repository under coursework/. That includes a known bug in Assignment 1 Q2.4, which the model-selection page lets you toggle. The assignment questions are paraphrased here. No university handouts, slides or datasets are served by this site. The Hitters data comes from the public ISLR R package.

The source repository on GitHub is private for now.