Segmented Regression for Non-Constant Relationships

by Jeff Meyer

by Jeff Meyer

We often have a continuous predictor in a model that we believe has non-constant relationship with the dependent variable along the predictor’s range. But how can we be certain? What is the best way to measure this?

Sometimes including a quadratic term will capture the change in the slope as we move from the bottom of the range to the top of the range. But a quadratic term only works in two situations:

  1. The rate of change increases and then at some point decreases, or:
  2. The opposite happens – the rate of change decreases and at some point increases.

We could also create a categorical variable. Each category within the categorical variable would represent a specific range within the continuous variable.

However, the coefficients for the new categorical variable would no longer represent the expected change in the dependent variable per unit change in the predictor.

The coefficients would represent the mean change in the dependent variable as compared to the base category of the predictor.

You could also split your data set into subset data sets. Each new data set would consist of different ranges of your continuous predictor. But there are several issues that could arise from this. For example, the power of your analysis could be significantly diminished. Your ability to test for interactions might also be impacted. So this is not an approach that I would recommend using.

I would suggest running a segmented (or piecewise) regression. A segmented regression allows you to generate different slopes for specific values of your continuous predictor. Instead of having several separate models, you have just one.

For example, let’s look at regressing income (in thousands of dollars) on years of education:

For every year of education, we expect income to increase by approximately $3,949. It doesn’t matter what level of education one has obtained. Put in an additional year of schooling and you’ll make an additional $3,949 per year.

Here’s the graph of this model:

Does it make sense that this rate of increase would remain the same for each level of education? For example, does someone with 11 years of education make about $4,000 less than someone with a high school education

Well, we can make a split at 11.99 years of education to find out:

The first slope, educ1a, is the increase in salary per year of education up to 12 years. For example, someone who went to school up to 11th grade would earn, on average, 10,352 + 11 x 1,040 = $21,792 per year.

Those with more than 12 years of education would earn an additional $4,938 per year for every year of education greater than 12.

Notice in the graph of this model that the y-intercept is no longer -21:

Should we expect an increase for those with a college degree compared to those with 1 to 3 years of college? Let’s add an additional segmentation to find out.

We have now modeled three different slopes for expected salary per number of years of education. The table below shows the average income levels at specific years of education.

Here’s the graph of this model:

Years of Education


Mean Income in Thousands


$9.061 +( 11.999 x 1.23)



$9.061 +( 11.999 x 1.23)+(1 x 4.13)



$9.061 +( 11.999 x 1.23)+ (4 x 4.13)



$9.061 +( 11.999 x 1.23)+ (4 x 4.13)+(1 x 6.43)



Jeff Meyer is a statistical consultant with The Analysis Factor, a stats mentor for Statistically Speaking membership, and a workshop instructor. Read more about Jeff here.

{ 2 comments… read them below or add one }


Hi Jeff,
I am interested in you opinion about using the segmented regression concept to Cox PH regression. Naturally the intercepts are no longer relevant / needed.
Thank you,


Jeff Meyer

Hi Horia,

I don’t consider myself an expert in Cox PH regression. The book “Flexible Parametric Survival Analysis Using Stata: Beyond the Cox Model” has a small discuss about it. The book uses the term piecewise rather than segmented but they are generally interchangeable terms.

Here is a link for piecewise exponential models:

Sorry I can’t give you a definitive answer.



Leave a Comment

Please note that, due to the large number of comments submitted, any comments on problems related to a personal study/project will not be answered. We suggest joining Statistically Speaking, where you have access to a private forum and more resources 24/7.

Previous post:

Next post: