Author Topic: Advanced math help (Regression analysis)  (Read 1203 times)

jefnvk

  • friend
  • Senior Member
  • ***
  • Posts: 1,478
  • I'll sleep away the days and ride the nights...
Advanced math help (Regression analysis)
« 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.
I still say 'Give Detroit to Canada'

drewtam

  • friend
  • Senior Member
  • ***
  • Posts: 1,985
Advanced math help (Regression analysis)
« Reply #1 on: March 15, 2006, 07:02:15 PM »
This is a linear algebra problem...

How good are you with matrix math?
I’m not saying I invented the turtleneck. But I was the first person to realize its potential as a tactical garment. The tactical turtleneck! The… tactleneck!

Telperion

  • friend
  • Member
  • ***
  • Posts: 140
Advanced math help (Regression analysis)
« Reply #2 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.

280plus

  • friend
  • Senior Member
  • ***
  • Posts: 19,131
  • Ever get that sinking feeling?
Advanced math help (Regression analysis)
« Reply #3 on: March 16, 2006, 01:44:32 AM »
Ok, now my head is starting to hurt... shocked

Cheesy
Avoid cliches like the plague!

Werewolf

  • friend
  • Senior Member
  • ***
  • Posts: 2,126
  • Lead, Follow or Get the HELL out of the WAY!
Advanced math help (Regression analysis)
« Reply #4 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.
Life is short, Break the rules, Forgive quickly, Kiss slowly, Love
truly, Laugh uncontrollably, And never regret anything that made you smile.

Fight Me Online

jefnvk

  • friend
  • Senior Member
  • ***
  • Posts: 1,478
  • I'll sleep away the days and ride the nights...
Advanced math help (Regression analysis)
« Reply #5 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.
I still say 'Give Detroit to Canada'

Tallpine

  • friends
  • Senior Member
  • ***
  • Posts: 23,172
  • Grumpy Old Grandpa
Advanced math help (Regression analysis)
« Reply #6 on: March 16, 2006, 07:22:16 AM »
ah ... bad memories from college ....  Wink
Freedom is a heavy load, a great and strange burden for the spirit to undertake. It is not easy. It is not a gift given, but a choice made, and the choice may be a hard one. The road goes upward toward the light; but the laden traveller may never reach the end of it.  - Ursula Le Guin

drewtam

  • friend
  • Senior Member
  • ***
  • Posts: 1,985
Advanced math help (Regression analysis)
« Reply #7 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
I’m not saying I invented the turtleneck. But I was the first person to realize its potential as a tactical garment. The tactical turtleneck! The… tactleneck!

Azrael256

  • friend
  • Senior Member
  • ***
  • Posts: 2,083
Advanced math help (Regression analysis)
« Reply #8 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!

280plus

  • friend
  • Senior Member
  • ***
  • Posts: 19,131
  • Ever get that sinking feeling?
Advanced math help (Regression analysis)
« Reply #9 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
Avoid cliches like the plague!