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 6327399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:16:23+00:00 2026-05-24T17:16:23+00:00

I have two linear fits that I’ve gotten from lm calls in my R

  • 0

I have two linear fits that I’ve gotten from lm calls in my R script. For instance…

fit1 <- lm(y1 ~ x1)
fit2 <- lm(y2 ~ x2)

I’d like to find the (x,y) point at which these two lines (fit1 and fit2) intersect, if they intersect at all.

  • 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-05-24T17:16:24+00:00Added an answer on May 24, 2026 at 5:16 pm

    One way to avoid the geometry is to re-parameterize the equations as:

    y1 = m1 * (x1 - x0) + y0
    y2 = m2 * (x2 - x0) + y0
    

    in terms of their intersection point (x0, y0) and then perform the fit of both at once using nls so that the returned values of x0 and y0 give the result:

    # test data
    set.seed(123)
    x1 <- 1:10
    y1 <- -5 + x1 + rnorm(10)
    x2 <- 1:10
    y2 <- 5 - x1 + rnorm(10)
    g <- rep(1:2, each = 10) # first 10 are from x1,y1 and second 10 are from x2,y2
    
    xx <- c(x1, x2)
    yy <- c(y1, y2)
    nls(yy ~ ifelse(g == 1, m1 * (xx - x0) + y0, m2 * (xx - x0) + y0),
        start = c(m1 = -1, m2 = 1, y0 = 0, x0 = 0))
    

    EDIT: Note that the lines xx<-... and yy<-... are new and the nls line has been specified in terms of those and corrected.

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

Sidebar

Related Questions

I would like to have two linear layouts inside a third parent layout. I
I have two similar functions that I would like to combine so that I
I have two set of samples that are time independent. I would like to
I have a linear-layout (vertically-oriented) that contains two nested linear layouts inside of it.
I created one linear layout and I have added two relative layout. I wish
Have two folders with approx. 150 java property files. In a shell script, how
I have two classes (MVC view model) which inherits from one abstract base class.
here in above screen, i have two linear layouts, one for two TextView and
I have two git repositories that are tangentially related. Namely, content of one was
Given two vectors X and Y , I have to find their correlation, i.e.

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.