Stata FAQ How can I run a piecewise regression in Stata?
Say that you want to look at the relationship between how much a child talks on the phone and the age of the child. You get a random sample of 200 kids and ask them how old they are and how many minutes they spend talking on the phone. You start with a scatterplot of the data like below. use http://www.ats.ucla.edu/stat/stata/faq/talk, clear twoway (scatter talk age) (lfit talk age) Looking at this you are not happy with the nonlinearity that you see in the data, so try to add a quadratic fit. twoway (scatter talk age) (lfit talk age) (qfit talk age) Thinking about this more, you decide that you think that the amount of time that kids talk on the phone changes dramatically at age 14, and that the slope might change at that age as well. You think that a piecewise regression might make more sense, where before age 14 there is an intercept and linear slope, and after age 14, there is a different intercept and different linear slope, kind of like pictured below with just freehand drawing o