2
$\begingroup$

I'm looking for a good tutorial on how to calculate a "line of best fit" for non-linear data.

I found this site: http://easycalculation.com/statistics/learn-regression.php which gives a very good tutorial on calculating a linear equation, but I can't seem to find a similar guide for non-linear data.

The closest I could find was this: http://www.arachnoid.com/sage/polynomial.html which starts out promising, but I began to understand less and less as it continued (compared to linear regression, where the most difficult concept to grasp was squares and sums).

I have very little mathematical education, so that's the stumbling block here. Are there any simple means of calculating polynomial regression (I believe that's the term), or is it probably above my head if I don't understand the second link?

(I'm creating a program to calculate and use the equation)

Thank you

$\endgroup$
  • $\begingroup$ Regression will require at least a basic knowledge of linear algebra. $\endgroup$ – Jemmy Sep 30 '14 at 15:44
  • $\begingroup$ So if I don't know what that is, I'm probably out of luck for the time being? I managed to easily get a program working for linear regression; does that require knowledge of linear algebra? And after more searching, I found this had2know.com/academics/quadratic-regression-calculator.html , but it requires using matrices. I understand matrices conceptually, but have never done any math on them. $\endgroup$ – Carcigenicate Sep 30 '14 at 15:47
  • $\begingroup$ You're throwing around the word "nonlinear" too much. Fitting a polynomial by least squares is linear regression. It is a mistake to think that the reason linear regression is called that is that one is fitting a line. See this earlier question: math.stackexchange.com/questions/75959/… math.stackexchange.com/questions/75959/… $\endgroup$ – Michael Hardy Sep 30 '14 at 16:00
  • $\begingroup$ Thank you. Like I said, I have very little math schooling (nothing past Applied Grade 12); I'm guessing on the terminology. All I know is I want an equation to fit to data that doesn't necessarily form a straight line. $\endgroup$ – Carcigenicate Sep 30 '14 at 16:02
1
$\begingroup$

Let $$ X = \begin{bmatrix} 1 & x_1 & x_1^2 \\ \vdots & \vdots & \vdots \\ 1 & x_n & x_n^2 \end{bmatrix}. $$ Let $$ Y = \begin{bmatrix} y_1 \\ \vdots \\ y_n \end{bmatrix}. $$ Then the three entries in the $3\times 1$ matrix $(X^T X)^{-1}X^TY$ are the least-squares estimates of the coefficients in $y = \alpha+\beta x+\gamma x^2$.

To use this, you would need to be able to do transposition, inversion, and multiplication of matrices.

$\endgroup$
  • $\begingroup$ I still don't understand any of that; but it's the simplest explanation I've seen. I'll come back to this once I understand the underlying concepts. Thank you. Much appreciated. $\endgroup$ – Carcigenicate Sep 30 '14 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.