matlab's regress

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

matlab's regress

Angus McMorland-2
Hi all,

I've been in need of the equivalent of matlab's regress function which
performs multilinear regression. After a bit of google searching, I
found this old code from ancient history:

http://osdir.com/ml/python.scientific.user/2004-04/msg00029.html

However, after a quick spruce-up to current scipy and numpy notation
(which I could post here if it's useful) it seems, from a quick test,
to perform as advertised.

Here begin my questions. I have looked through the scipy
documentation, and can't see any other routines that do the same task,
apart, perhaps from the odr module or using routines from the lapack
or blas libraries. These latter options, however, I don't know
anything about, and there aren't readily applicable examples floating
around to base my effort on.

(1) Have I missed some multilinear regression routine directly
implemented in scipy? If yes, how can we improve the documentation so
the next person can find it more easily.

(2) If there isn't an equivalent routine, would it be useful to
include this one? It could perhaps go in scipy.linalg.

Thanks for your thoughts,

Angus.
--
AJC McMorland, PhD candidate
Physiology, University of Auckland

(Nearly) post-doctoral research fellow
Neurobiology, University of Pittsburgh
_______________________________________________
SciPy-user mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: matlab's regress

Wes McKinney
On Apr 7, 2008, at 11:54 PM, Angus McMorland wrote:
>
>
> (1) Have I missed some multilinear regression routine directly
> implemented in scipy? If yes, how can we improve the documentation so
> the next person can find it more easily.

scipy.stats.models in the current SVN branch has a bunch of modelling  
tools for least-squares estimation, robust estimation, and some other  
statistical methods. It's more object oriented than the matlab  
equivalent, but you can do simple multivariate regressions without  
too much work:

 >>> import scipy.stats.models.regression as R
 >>> from numpy.random import standard_normal as W
 >>> X = W((40,10))
 >>> Y = W((40,))
 >>> model = R.OLSModel(design=X)
 >>> result = model.fit(Y)
 >>> result.beta
array([-0.2296546 , -0.15835343, -0.07127199,  0.02934717,  0.15778939,
         0.14087653,  0.09279021, -0.03412604, -0.28726236,  
0.03078167])


_______________________________________________
SciPy-user mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: matlab's regress

Alan G Isaac
In reply to this post by Angus McMorland-2
numpy.linalg.lstsq

Also look at:
http://svn.scipy.org/svn/scipy/trunk/scipy/stats/models/regression.py

hth,
Alan Isaac



_______________________________________________
SciPy-user mailing list
[hidden email]
http://projects.scipy.org/mailman/listinfo/scipy-user
Loading...