Basis functions
The unifying through-line of module 7: replace with and you are still doing linear regression. Polynomial regression, step functions, and regression splines are all the same idea , a different choice of stuffed into the design matrix; OLS does the rest.
Definition (prof’s framing)
“Instead of looking at directly we’re going through basis functions, and that’s a very general term, a very powerful term that has many many versions.” - L16-beyondlinear-1
The model becomes
The are fixed, known transformations chosen ahead of time. The design matrix is built from values; everything else (closed form , sampling distribution, CIs, F-tests) carries over unchanged because the model is linear in .
Notation & setup
- : scalar predictor (the slide deck does the one-predictor case for clarity; multivariate version is just the GAM).
- : the chosen basis functions. The intercept is the implicit "".
- Design matrix dimensions , same shape as MLR.
Each column is one basis function evaluated across the data; each row is one observation.
The four module-7 instances
| Method | Basis functions |
|---|---|
| Polynomial regression (degree ) | |
| Step functions ( cutpoints) | |
| Cubic regression spline ( knots) | |
| Natural cubic spline ( interior knots) | re-parametrised version with linearity enforced past the boundary knots |
Smoothing splines and local regression drop the basis-function frame , they minimize over a function directly rather than over . They are deliberately separated by the prof from the basis-function methods.
Insights & mental models
“It’s nonlinear, but linear. It’s linear in the parameters , but it’s nonlinear in what you get.” - L16-beyondlinear-1
This slogan covers all of polynomial regression, step functions, and regression splines. The whole module is one trick repeated with richer columns in .
The book also collects this idea into one section (ISLP §7.3): polynomials, indicators, splines, wavelets, Fourier , all just choices of . Once the design matrix is built, every linear-model tool from module 3 (least squares, /-tests, CIs, residual diagnostics) is in scope.
Exam signals
“There’s a commonality, right? We’re talking about basis functions, but all you have to do is fit it with regression.” - L16-beyondlinear-1
“We’re now going to do something more than just finding betas.” - L16-beyondlinear-1 (introducing smoothing splines as the break with the basis-function frame)
The contrast is itself a fair-game exam point: which methods in module 7 fit by OLS on a basis (poly, step, regression spline), which need a different objective (smoothing spline, local regression).
Pitfalls
- The design matrix gets wide fast , knots in a cubic spline already gives columns (intercept included). High-degree polynomial × many knots = collinearity, instability.
- “Linear in ” does not mean the fitted curve is linear in . Don’t confuse the two.
- The truncated-power basis is the textbook basis but R uses
bs()(B-spline) which gives the same fit with different columns. The prof: “I don’t know why they call it BS.” Cosmetic , same predictions. - For the natural-spline basis (Exercise 7.3), the textbook formula is asymmetric: , then with . Easy to mis-write the indexing.
Scope vs ISLP
- In scope: the basis-function frame as the unifier of module 7; the design-matrix construction; that OLS / its inference toolbox carries over.
- Look up in ISLP: §7.3 (the explicit “polynomial and step are special cases” framing); §7.4 for the spline-basis derivation.
- Skip in ISLP: wavelets and Fourier-basis examples , name-checked in §7.3, not in lecture.
Exercise instances
- Exercise 7.3: derive for a natural cubic spline in
yearwith one interior knot at 2006 from the textbook basis formula. Pure design-matrix construction, no fitting. - Exercise 7.4: write
mybs(),myns(),myfactor()to build the full additive design by hand and verify matches whatgam()returns. The “two different design matrices, same prediction” punchline = different bases, same column space.
How it might appear on the exam
- “Given a basis , write down the design matrix” , pure construction, like Exercise 7.3.
- “Why is fitting a polynomial / cubic spline / step function still ‘linear regression’?” , recite the linear-in- slogan.
- “How many parameters does a degree- polynomial / step function with cuts / cubic spline with knots have?” , degree-of-freedom counting (1 + for poly, for step including intercept, for cubic spline).
- Method-comparison: given two different bases that give the same fitted values, explain why (same column space).
Related
- polynomial-regression: basis functions ; the simplest instance.
- step-functions: basis functions = indicators of intervals.
- regression-splines: truncated-power basis, the headline module-7 application.
- generalized-additive-models: the multivariate generalisation: stack basis-function blocks for each predictor.
- linear-regression: the host model that the basis-function trick rides on.
- design-matrix-and-hat-matrix: what’s actually being constructed.