Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8962755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:12:12+00:00 2026-06-15T16:12:12+00:00

I am using the R package segmented to calculate parameters for a model, in

  • 0

I am using the R package segmented to calculate parameters for a model, in which the response variable is linearly correlated with the explanatory variable until a breakpoint, then the response variable becomes independent from the explanatory variable. In other words, a segmented linear model with the second part having a slope = 0.
What I already did is:

linear1 <- lm(Y ~ X)
linear2  <- segmented (linear1, seg.Z = ~ X, psi = 2)

This gives a model that have a very good first line, but the second line is not horizontal (but not significant). I want to make the second line horizontal. (psi = 2 is the place where I observed a breakpoint.)

Also, when I use “abline” to show the broken line on the plotting, it only show the first part of the model, giving a warning: “only using the first two of 4 regression coefficients”. How could I display both parts of the model?

To input my data into R:

X <- c(0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0)
Y <- c(1.31, 1.60, 1.86, 2.16, 2.44, 2.71, 3.00, 3.24, 3.57, 3.81, 3.80, 3.83, 3.78, 3.94, 3.75, 3.89)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:12:13+00:00Added an answer on June 15, 2026 at 4:12 pm

    This is as easy as using the plot method for segmented class objects provided by the package segmented and linked in the help for segmented

    Assuming your data is in the data.frame d

    linear2  <- segmented (linear1, seg.Z = ~ X, psi = 2, data = d)
    plot(linear2)
    points(Y~X, data = d)
    

    enter image description here

    An easy way to fudge a horizontal line would be to replace the coefficient with value required for that line to be horizontal

    fudgedmodel <- linear2
    fudgedmodel$coefficients[3] <- - fudgedmodel$coefficients[2]
    plot(fudgedmodel)
    points(Y~X, data = d)
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using caret package for R to select variables for my model. When
I have installed my dependencies using bundle package Then transferred them to the offline
Using the segmented package to create a piecewise linear regression I am seeing an
I'm using the strucchange package in order to determine where my curve model segments.
I am using package qvalue which has the following pre-processing step if(min(p)<0 || max(p)>1)
I am trying to create an installer using Package Maker, which installs a plugin
I'm using the igraph package in R to do something rather simple: Calculate the
Hi I am using package-maker of Mac OS to create installer package for Mac
When I am using subfig package in latex, it gives some errors: Package subfig
I'm using the package android.telephony.SmsManager to send an SMS message from within my application,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.