Armed Polite Society

Main Forums => The Roundtable => Topic started by: jefnvk on March 15, 2006, 06:14:45 PM

Title: Advanced math help (Regression analysis)
Post by: jefnvk on March 15, 2006, 06:14:45 PM
I am looking for a source that can give me a step-by-step instruction (or even a general overview) of how to do Quadratic and Logarithmic Regression best fit lines.  All the online sources I have found  are some sort of pre built calculator.  Since this is for a graphing program I am currently developing, I need the implementation, not a calculator.  Or, if anyone can explain, that would be cool too.
Title: Advanced math help (Regression analysis)
Post by: drewtam on March 15, 2006, 07:02:15 PM
This is a linear algebra problem...

How good are you with matrix math?
Title: Advanced math help (Regression analysis)
Post by: Telperion on March 15, 2006, 07:08:13 PM
Ah, a chance to use my degree! Cheesy

Typically you'd use the method of least squares to fit a curve to the data.  Suppose you have points (x_i,y_i) with i=1 .. n, and you want to fit it with some polynomial function p(x).  For a quadratic, you'd have p(x)=ax^2 + bx + c, where you want to choose a, b, and c to minimize the value of

L = sum (y_i - p(x_i))^2
   = sum (y_i - (ax_i^2 + bx_i + c))^2

Take partial derivatives of L with respect to a, b, and c, and you will have 3 linear equations in terms of a, b, and c that can be solved through the usual means.

I'm not sure what logarithmic model you are thinking of, but a lot of nonlinear curve-fitting problems can be reduced to the linear case by some clever variable substituion.
Title: Advanced math help (Regression analysis)
Post by: 280plus on March 16, 2006, 01:44:32 AM
Ok, now my head is starting to hurt... shocked

Cheesy
Title: Advanced math help (Regression analysis)
Post by: Werewolf on March 16, 2006, 04:07:09 AM
Any decent college level statistics textbook designed for engineering students will provide you with both the theory and the practical information you require.

That said:

Ever hear the phrase - reinventing the wheel. Unless your project is purely for fun or training why bother?

Regression analysis prior to the invention of the computer was a real pain involving literally 1000's of individual calculations to do on any data set with a reasonable number of data points - and that's linear regression. Doing a regression analysis on a non-linear data set was nigh on to impossible or took a very very long time.

Now you can just drop your data into Excel or a statistics program, run a regression analysis of the type you want, get the graph and get the regression equation to go along with it all in a matter of seconds ever for very large data sets. I do it almost every day in my job. The thought of having to do it the old way gives me the willies even thinking about it.
Title: Advanced math help (Regression analysis)
Post by: jefnvk on March 16, 2006, 07:14:40 AM
The program is for a class, it is a sensor data gathering and graphing program for the Palm OS.  I have definitely looked, there is no easy drop in that I can use.  Unfortunately, it cannot just be dropped from the program either.

Logarithmic I have figured out in a linear way.  I'll give that a try Telperion, that definitely looks like the easy to understand version of the few directions that I have found.

Engineering statistics textbooks, at least the few that I have looked at, that me and my friends have used for our statistics classes, stop at linear regression.  The general statistics classes that are required here are not too difficult, many topics were not covered because they involved calculus, and that was determined to be outside the difficulty of the class.

As for my matrix math skills, not too bad, but not all that great.  I can understand all the matrix operations going on on the board right now in Cryptography, if that gives you any idea of my skills.
Title: Advanced math help (Regression analysis)
Post by: Tallpine on March 16, 2006, 07:22:16 AM
ah ... bad memories from college ....  Wink
Title: Advanced math help (Regression analysis)
Post by: drewtam on March 16, 2006, 06:36:07 PM
I just realised that I never bought my linear alg. text, must have borrowed it from my roomate at the time.

Anyway, heres a really good source:
http://mathworld.wolfram.com/LeastSquaresFitting.html

with all the math and explanation, and links to other related topics.

Drew
Title: Advanced math help (Regression analysis)
Post by: Azrael256 on March 16, 2006, 11:42:56 PM
Quote
Ok, now my head is starting to hurt...
Me too.  Unless there's a dollar sign in front of it, it makes no sense to me.  (You guys can laugh.  It's funny when the Jew says it about himself.)

I can't provide any practical answers, but I sure can get in the way.

Good luck!
Title: Advanced math help (Regression analysis)
Post by: 280plus on March 17, 2006, 01:01:01 AM
Quote
Unless there's a dollar sign in front of it, it makes no sense to me.
I'm not Jewish but +1 on that anyways...

Face it, without a dollar sign numbers are worthless.

Cheesy