views:

1272

answers:

3

Hello,

I am currently using scipy's linregress function for single regression. I am unable to find if the same library, or another, is able to do multiple regression, that is, one dependent variable and more than one independent variable. I'd like to avoid R if possible. If you're wondering, I am doing FX market analysis with the goal of replicating one currency pair with multiple other currency pairs. Anyone help? Thanks,

Thomas

+1  A: 

I'm not sure if this is what you need, but the Modular toolkit for Data Processing (MDP) libray recently implemented multivariate linear regression. It is under LGPL license.

nikow
thanks, hadn't heard of MDP - I'll check it out.
Thomas Browne
+1  A: 

I think it's possible to do multiple variables if you know how to formulate the problem as a linear algebra problem. Gil Strang's "Introduction to Applied Mathematics" has a nice chapter describing it.

If you have m equations with n unknowns, where m > n, you can write them as:

a11*x1 + a12*x2 + .... + a1n*xn = b1
a21*x1 + a22*x2 + .... + a2n*xn = b2

am1*x1 + am2*x2 + .... + amn*xn = bn

In matrix notation

A*x = b

If you pre-multiply both sides by A(transpose), you now have an nxn square matrix that you can solve using standard linear algebra techniques like LU decomposition.

duffymo
thanks duffymo - yep I may have to program it myself. I'll be honest and say that I haven't done matrix math for a while but I can always brush up ;)
Thomas Browne
+4  A: 

Use the OLS class [http://www.scipy.org/Cookbook/OLS] from the SciPy cookbook.

wierob