5 Change of Slope Models

1 Change of Slope Model

Change of Slope Model

The change of slope model/broken-stick regression is given by (1.1)yt=β0+β1t+β2ReLU(t−c)+εt, with εt∼i.i.dN(0,σ2), ReLU(t−c)=max{t−c,0}.[1]

For t≤c, the slope of the regression line is β1, while for t>c, is β1+β2. The parameters here are c,β0,β1,β2,σ.

If c were known, then (1.1) is a linear: y=Xcβ+c, here Xc=(11ReLU(1−c) ⋮⋮⋮1nReLU(1−c)).

2 Parameter Estimation

2.1 MLE

We also use MLE: RSS(c)=minβ0,β1,β2∑t=1n(yt−β0−β1t−β2ReLU(t−c))2. After numerically solving this, the model becomes linear as mentioned just now, so β^=(β^0,β^1,β^2)T=(Xc^TXc^)−1Xc^Ty. Then σ^=RSS(c^)n−3.

2.2 Uncertainty Quantification

Now switch to Bayes. Suppose prior: β0,β1,β2,log⁡σ∼i.i.dUnif(−C,C) for a large C. For c, it is also uniform and the range is 1,⋯,n. However, c can't be 1 or n: when c=1, β0+β1t+β2ReLU(t−1)=β0+β1t+β2(t−1) is linear. Same for c=n. Therefore c∼Unif{2,⋯,n−1}.
Then π(c|data)∝(1RSS(c))n−32|XcTXc|−121{c=2,⋯,n−1}. Given c, the model is linear. By Homework 1 Problem 4, RSS(c)σ2|data,c∼χn−32. Finally, β|data,c,σ∼N3(β^c,σ2(XcTXc)−1),β^c=(XcTXc)−1XcTy.

2.3 Posterior Sampling for Uncertainty Quantification

Drawing posterior samples from unknown parameters is a useful way to visualize the uncertainty.

Algorithm (Posterior Sampling)

  1. Obtain samples c(1),⋯,c(N) by sampling with replacement from {2,⋯,n} with probability weights given by π(c|data) here.
  2. For each j=1,⋯,N:
    1. Fix c=c(j).
    2. Calculate RSS(c),β^c by implementing linear regression with fixed c.
    3. Generate χ2∼χn−32, then take σ(j)=RSS(c)χ2.
    4. Take β(j)∼N(β^c,(σ(j))2(XcTXc)−1) to be a generated random vector.

So now we have (c(j),β0(j),β1(j),β2(j),σ(j)) for j=1,⋯,N, then we can fit values t↦β0(j)+β1(j)t+β2(j)ReLU(t−c(j)),t=1,⋯,n.

If we want to obtain posterior samples for yt∗ for future t∗, then based on the algorithm, in step 2, add 2.5: generate yt∗(j)∼N(β0(j)+β1(j)t∗+β2(j)ReLU(t∗−c(j),(σ(j))2).

3 More Change of Slope

If we want to introduce one more break point: yt=β0+β1t+β2ReLU(t−c1)+β3ReLU(t−c2)+εt, with εt∼i.i.dN(0,σ2), we can also write it as y=Xcβ+ε,Xc=(11ReLU(1−c1)ReLU(1−c2)⋮⋮⋮⋮1nReLU(n−c1)ReLU(n−c2)). Then we can also have posterior π(c|data)∝(1RSS(c))n−42|XcTXc|−12. For more break points, we can consider yt=β0+β1t+∑j=1kβj+1ReLU(t−cj)+εt.


  1. We can also denote this as (⋅)+. ↩︎