My Math Forum > Math Fitting line to data
 User Name Remember Me? Password

 Math General Math Forum - For general math related discussion and news

 October 9th, 2019, 05:23 AM #1 Newbie   Joined: Oct 2019 From: Tabriz Posts: 3 Thanks: 0 Fitting line to data I want to fit two lines to the data in the attached image; one line from the top and one line from the bottom. Like what you see in the attachment. What is the best way to do this? Is there any software that can do this? 1111.jpg thank you for your attention
 October 9th, 2019, 05:41 AM #2 Senior Member   Joined: Jun 2019 From: USA Posts: 310 Thanks: 162 It depends on what you want the lines to represent. This kind of resembles the confidence interval of the curve fit (also known as the ScheffĂ© band), although unless you set the confidence level extremely high, it would be a much tighter fit than that. You could also estimate a precision interval of the curve fit using the same technique. In both of these cases, you would start by curve-fitting the data (which you can do in Excel) and then calculating the standard error of the fit (which you can also do in Excel. I don't know if this is what you want, though.
 October 9th, 2019, 06:03 AM #3 Newbie   Joined: Oct 2019 From: Tabriz Posts: 3 Thanks: 0 Thanks for answering, What I need here is the slope and intercept of the two upper and lower lines. As far as I know, in Excel, only one line fits into the data.
October 9th, 2019, 06:04 AM   #4
Senior Member

Joined: Oct 2009

Posts: 884
Thanks: 340

Quote:
 Originally Posted by RHassanpour Thanks for answering, What I need here is the slope and intercept of the two upper and lower lines. As far as I know, in Excel, only one line fits into the data.
Yes, but the red curves are not straight lines if you look at it. So you can't get a slope and intercept.

Try quantile regression for what you want.

Last edited by skipjack; October 9th, 2019 at 09:04 AM.

October 9th, 2019, 06:32 AM   #5
Senior Member

Joined: Jun 2019
From: USA

Posts: 310
Thanks: 162

Quote:
 Originally Posted by Micrm@ss Yes, but the red curves are not straight lines if you look at it. So you can't get a slope an intercept.
That's not even the problem. Polynomial, exponential, etc. regressions are totally possible; even a linear regression would get you some kind of estimate.

The problem is, regressions try to fit the data set (as a whole). OP is trying to fit the upper limit and lower limit of the data set. There is no simple or unique way to define this.

Does quantile regression address this somehow? (I'm honestly not familiar with the concept, and couldn't follow the Wikipedia article at first glance.)

October 9th, 2019, 07:25 AM   #6
Senior Member

Joined: Oct 2009

Posts: 884
Thanks: 340

Quote:
 Originally Posted by DarnItJimImAnEngineer That's not even the problem. Polynomial, exponential, etc. regressions are totally possible; even a linear regression would get you some kind of estimate.
That was totally not my remark. Please read it more carefully.

October 9th, 2019, 08:06 AM   #7
Senior Member

Joined: Jun 2019
From: USA

Posts: 310
Thanks: 162

Quote:
 Originally Posted by Micrm@ss That was totally not my remark. Please read it more carefully.
No, I know. He was asking how to get the slope and intercept of a curve, and you were pointing out neither curve was a straight line and therefore neither had a singular slope or intercept. I got that.

I was skipping ahead and responding to the next question. OP might have asked, "If we make it a straight line instead, how can we find the slope and intercept?" Or, "If we model it as a quadratic equation, how can we get the coefficients of the quadratic equation?" Except the only good way I saw to do that was with some kind of regression, and linear/polynomial/exponential/etc. regression tries to fit the entire data set. We would need to select some form of "edge detection" algorithm to select points to represent the upper boundary and the lower boundary, and curve fit each of these. This, of course, begs the definition of what constitutes an "edge point."

And that's kind of why I was asking what the lines were supposed to represent in the first place. Is OP looking for something like, "draw a curve that will contains 95 % of the data points from an infinite set?" Because we can do this with some assumptions about the probability distribution. Or do they just want a curve that looks somewhat like the general shape we discern as humans? Because in that case, I'd just grab a French curve, pick three points, and trace it.

(And seriously, if quantile regression does what they want, then I have egg on my face. I still don't understand what it is or does.)

 October 9th, 2019, 08:36 AM #8 Newbie   Joined: Oct 2019 From: Tabriz Posts: 3 Thanks: 0 Thanks for your valuable comments, As I mentioned above, I need the slope and intercept of the upper limit and lower limit of the data set in both linear and nonlinear fitting. My question was, is there any particular software or method to do this or should it be done manually? The red lines drawn do not matter.

 Tags data, fitting, line

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post d423 Pre-Calculus 2 October 1st, 2018 09:41 PM datameng Linear Algebra 2 September 3rd, 2014 05:30 AM Simon39 Abstract Algebra 4 November 29th, 2013 09:41 PM bloons Advanced Statistics 1 October 26th, 2010 04:14 AM dimper129 Linear Algebra 0 October 7th, 2009 07:01 AM

 Contact - Home - Forums - Cryptocurrency Forum - Top

Copyright © 2019 My Math Forum. All rights reserved.