Linear Regression (FIT2086)
Context: FIT2086_MOC Β· the first supervised model of the unit β point estimation, intervals and testing now applied to a mean that varies with predictors Β· the rigorous version of Linear and Polynomial Regression Β· fit β‘ ML β Least Squares as Maximum Likelihood Β· design-matrix tricks β Predictor Transformations (Indicators, Polynomials, Interactions) Β· choosing which predictors β Model Selection and Information Criteria (AIC, BIC)
Quick Revision
- π― Objective: let the conditional mean of move linearly with the predictors β estimate by least squares β predict, and read one coefficient at a time.
- π¦ Core Components: simple β 2 free parameters | multiple β | fit measured by | scale-free fit by .
- β‘ Key Constraint: always rises when a predictor is added β it can rank fit but can never choose a model; and least squares needs or the solution is non-unique.
π How It Works
1. Supervised Learning Setup
- Data shape β variables measured on individuals; predict one variable from the remaining .
- Target β also response / outcome; treated as a random variable because measurement carries error.
- Predictors β also explanatory variables / covariates / exposures; assumed known without error.
- Task split β categorical target βΉ classification (W7); numerical target βΉ regression (here).
- What is learned β an with ; βsupervisedβ because labelled examples exist. No fits perfectly.
2. From the Mean Model to a Line
- Baseline β , β one prediction for everybody, ignoring all other data.
- Upgrade β β the mean is now conditional on the predictor.
- Strict nesting β collapses the line back to the mean model with βΉ the mean model is a submodel, which is exactly why it serves as the reference.
- Payoff on the BP data β falls by using weight alone.
3. Reading the Parameters
- Simple form β β is the intercept ( at ), the regression coefficient (change in per one unit of ).
- Multiple form β β is when all ; is the change per unit of with the others held fixed.
- Worked reading β (BP on weight): average BP; at the model says β a nonsense extrapolation outside the observed range.
- Magnitude is not importance β depends on the predictorβs units, so it cannot rank predictors β standardise or use the -score (Model Selection and Information Criteria (AIC, BIC)).
4. Fitting by Least Squares
- Residual β β the modelβs error on an observation it was fitted to.
- Least-squares principle β pick the coefficients minimising the squared total error; smaller = better fit.
- Stationary equations β set both partials to zero (chain rule), then solve the resulting linear system:
- Two free properties of the solution β and β the fitted line leaves zero mean residual and residuals uncorrelated with the predictor. Structure left in a residual plot is therefore not linear-in- structure β it signals a needed transformation.
- Identifiability β requires ; with the minimiser is non-unique. Efficient algorithms solve the multiple-predictor case directly.
- Alternative losses exist β e.g. least absolute errors; squares win on simplicity, computational efficiency, and the normal-model connection.
5. β the Scale-Free Fit Score
- Why not β its scale is arbitrary; means nothing without a reference.
- Reference β β the of the intercept-only mean model.
- Definition β , the coefficient of determination; = no explanatory power, = data fully explained.
- Monotone in predictors β adding any predictor always increases β a predictor that raises it a lot is potentially important, but the ranking cannot be used to stop adding.
6. Predicting New Data
- Point prediction β for new predictor values .
- Full predictive distribution β the normal error model gives β probability statements, not just a number (Plug-in Prediction and Held-Out Evaluation).
- Sensitivity reading β sweep one predictor, hold the rest, and watch move β this is how a fitted model answers βwhat ifβ.
- Range discipline β predictions outside the observed predictor ranges are unsupported by the data.
π¬ Model
- Declared spaces β , design matrix (plus an intercept column), , .
- Mean function β ; only the mean is modelled β the spread is constant across .
- Objective (least squares) β
- Noise model β independently βΉ the LS estimates are the ML estimates β derivation and the two estimators in Least Squares as Maximum Likelihood.
π Exam Execution Trace & Applied Exercises
Applied Exercise
Problem: On the blood-pressure data the mean model gives . Regressing on weight gives ; adding age gives with . Report both values and predict for a , -year-old.
Final Extracted Output: rises ; predicted . Each extra kilogram adds , each extra year .
β οΈ Common Mistakes
- π‘ Using to pick a model β it is monotone in the predictor count, so the full model always wins β a complexity penalty is required (Model Selection and Information Criteria (AIC, BIC)).
- π‘ Comparing raw across predictors β scale-dependent; vs says nothing about importance unless the predictors share a scale or are standardised.
- π‘ Interpreting the intercept literally β is at , which is usually far outside the data (a person).
- π‘ Forgetting βholding the others fixedβ β in multiple regression is a partial effect; a coefficient can change sign when other predictors enter.
π§ Active Recall
Why is the mean model the right reference for , and what does that force to measure?
- Hint: Set .
Answer
- Short answer: The mean model is the linear model with all slopes zero, so is the of the worst sensible competitor; is the fraction of that baseline error removed by the predictors.
- Why: Nested submodel β , so always and .
Residuals from a least-squares fit are uncorrelated with by construction. What does a curved residual-vs- plot then tell you?
- Hint: Zero correlation β no structure.
Answer
- Short answer: Not that the fit failed on linear structure β that structure is already removed β but that the relationship is nonlinear in , so the predictor needs transforming.
- Why: is forced β any remaining pattern must be non-linear β apply or a polynomial expansion (Predictor Transformations (Indicators, Polynomials, Interactions)).
Why must least squares assume ?
Answer
- Short answer: With at least as many free coefficients as observations the minimiser is non-unique β infinitely many coefficient vectors drive to the same (often zero) value.
- Why: Underdetermined system β the stationary equations no longer pin down a single solution, so is not identifiable.