13 Lecture 04 - 2019

13.1 Standardizing variables

(x - mean(x)) / sd(x) or scale(x)

Result = mean of 0, sd of 1

Helps software fit

Value = 1 is equal to 1 SD

13.2 Plotting uncertainty - sample from posterior

(if multivariate normal)

  1. Approximate posterior from mean, standard deviation
  2. Sample from multivariate normal distribution of parameters
  3. Use samples to generate predictions that integrate over uncertainty

extract_samples returns a, b, sigma, … and you can plot each

13.3 Polynomials

Polynomials have bad behavior especially at the boundaries of the data

They don’t fit locally, and are not actually flexibly.

Eg. a polynomial of 3rd degree will necessarily have two turns - this has to happen irrespective of the data

13.4 Splines

Locally wiggly functions, combined by interpolation

Geocentric - describing relationships - not exploring them

13.5 Basis splines

Bayesian B-splines = P-splines

Similar to linear models but with synthetic variables

\(\mu = \alpha + w_{1} \beta_{1} + + w_{2} \beta_{2} + + w_{3} \beta_{3} + + w_{4} \beta_{4} + ...\)

Knots are often picked at equal intervals in data, though strategies vary

At each knot, the knot’s function is at 100%, moving away from it, the neighboring functions turn on

Parameters always have more uncertainty than predictions

Caution: over fitting

13.5.1 Recipe

  1. Choose knots - points where spline pivots
  2. Choose degree of basis functions - how wiggly, polynomial
  3. Find posterior distribution of weights