I have a three-piece linear regression model that I’m running in R to model body mass over age in a large population. My dataset is called hdata. Through an iterative procedure that runs through all combinations of breaks points, I have found the two breakpoints associated with the lowest residual squared error model. The code for my piecewise regression, with the two breakpoints specified is:
piecewise=lm(hdata$weight ~ hdata$age*(hdata$age < 0.7) + hdata$age*(hdata$age>=0.7 & hdata$age<2) + hdata$age*(hdata$age>2))
When I look at:
summary(piecewise)
I get the following output:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1723.012 210.042 8.203 3.67e-16 ***
hdata$age 18.494 1.089 16.975 < 2e-16 ***
hdata$age < 0.7TRUE -1690.051 210.476 -8.030 1.48e-15 ***
hdata$age >= 0.7 & hdata$age < 2TRUE -721.200 213.882 -3.372 0.000758 ***
hdata$age > 2TRUE 478.094 210.194 2.275 0.023016 *
hdata$age:hdata$age < 0.7TRUE 2022.896 45.477 44.481 < 2e-16 ***
hdata$age:hdata$age >= 0.7 & hdata$age < 2TRUE 603.453 30.532 19.764 < 2e-16 ***
hdata$age:hdata$age > 2TRUE NA NA NA NA
From these estimates, I would like to calculate the three intercepts, and the three slopes associated with the model, but I do not know how to do this. For simplicity, I’m calling the estimate associated with (Intercept) Est1, the estimate associated with hdata$age Est2, and so on…up to Est7. I think that the first intercept should be Est1 + Est3, and the first slope should be Est2 + Est6, but I could be wrong about that, and still don’t know how to calculate the other intercepts and slopes. Any help would be appreciated.