• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
The Analysis Factor

The Analysis Factor

Statistical Consulting, Resources, and Statistics Workshops for Researchers

  • Home
  • Our Programs
    • Membership
    • Online Workshops
    • Free Webinars
    • Consulting Services
  • About
    • Our Team
    • Our Core Values
    • Our Privacy Policy
    • Employment
    • Collaborate with Us
  • Statistical Resources
  • Contact
  • Blog
  • Login

Segmented Regression for Non-Constant Relationships

by Jeff Meyer 4 Comments

by Jeff Meyer

When you put a continuous predictor into a linear regression model, you assume it has a constant relationship with the dependent variable along the predictor’s range. But how can you be certain? What is the best way to measure this?

And most important, what should you do if it clearly isn’t the case?

Let’s explore a few options for capturing a non-linear relationship between X and Y within a linear regression (yes, really).

A Quadratic Term

Including a quadratic term will capture the change in the slope as you move from the bottom of X’s 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.

Making a Continuous Predictor Categorical

You 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.

Running Separate Models

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.

Segmented Regression

Better than running separate models is 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 every 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

Formula

Mean Income in Thousands

11.999

$9.061 +( 11.999 x 1.23)

$23.85

13

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

$27.99

15.99

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

$40.40

17

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

$46.82

Segmented regression is a great option when there are meaningful break points for X. It worked well here because both 12 years and 16 years of education are meaningfully different than other values.

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.

Four Critical Steps in Building Linear Regression Models
While you’re worrying about which predictors to enter, you might be missing issues that have a big impact your analysis. This training will help you achieve more accurate results and a less-frustrating model building experience.

Tagged With: continuous predictor, dependent variable, non-constant relationship, piecewise regression, quadratic terms, segmented regression, slopes

Related Posts

  • Why report estimated marginal means?
  • Recoding a Variable from a Survey Question to Use in a Statistical Model
  • A Strategy for Converting a Continuous to a Categorical Predictor
  • A Useful Graph for Interpreting Interactions between Continuous Variables

Reader Interactions

Comments

  1. Steve says

    September 21, 2021 at 1:56 pm

    What are the diagnostics for assessing the segments? Is there a way to determine an optimal number of segments, as there is with clusters in cluster analysis?

    Reply
  2. Jon K Peck says

    September 21, 2021 at 8:48 am

    Another approach that is often useful is to use a generalized additive model (GAM) this fits a smooth spline curve of various types – cubic splines are the most popular for each predictor.

    In SPSS Statistics, this is available via the STATS GAM extension command. From the help.
    This procedure calculates a generalized additive model (GAM). GAMs are linear in predictor terms that can be simple variables or various kinds of splines or polynomials. This preserves the simplicity of the linear model while allowing flexibly for predictors to have a nonlinear effect on the dependent variable. In addition, you can specify the error distribution and link function for the model.

    Reply
  3. horia says

    May 15, 2019 at 11:52 am

    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,
    Horia

    Reply
    • Jeff Meyer says

      May 16, 2019 at 10:08 am

      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:
      https://data.princeton.edu/wws509/stata/recidivism

      Sorry I can’t give you a definitive answer.

      Jeff

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Please note that, due to the large number of comments submitted, any questions 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.

Primary Sidebar

This Month’s Statistically Speaking Live Training

  • Member Training: Analyzing Pre-Post Data

Upcoming Free Webinars

Poisson and Negative Binomial Regression Models for Count Data

Upcoming Workshops

  • Analyzing Count Data: Poisson, Negative Binomial, and Other Essential Models (Jul 2022)
  • Introduction to Generalized Linear Mixed Models (Jul 2022)

Copyright © 2008–2022 The Analysis Factor, LLC. All rights reserved.
877-272-8096   Contact Us

The Analysis Factor uses cookies to ensure that we give you the best experience of our website. If you continue we assume that you consent to receive cookies on all websites from The Analysis Factor.
Continue Privacy Policy
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT