[SciPy-user] linear regression
Wed May 27 08:56:14 CDT 2009
> Is there a recommended way now of calculating the slope of a linear
> regression? Using the scipy.stats.linregress function gives a
> deprecation warning, apparently because that function uses the
> scipy.mean function:
> sage: import numpy
> sage: import scipy.stats
> sage: scipy.stats.linregress(numpy.asarray([4,3,2,1,2,3,4]),
> DeprecationWarning: scipy.stats.mean is deprecated; please update your
> code to use numpy.mean.
> Please note that:
> - numpy.mean axis argument defaults to None, not 0
> - numpy.mean has a ddof argument to replace bias in a more general
> scipy.stats.mean(a, bias=True) can be replaced by numpy.mean(x,
> axis=0, ddof=1).
> axis=0, ddof=1).""", DeprecationWarning)
> (-1.0, 5.0, -1.0, 1.9206748078018268e-50, 0.0)
> This is scipy 0.7.0.
This should be addressed in the SVN version. Please note that you might
see similar messages in other functions (var and samplevar) because any
functions that are duplicated with numpy have been or should be
depreciated in scipy.
I think there are many people who would like this function to disappear
because it is just simple linear regression (ie relationship between two
variables - http://en.wikipedia.org/wiki/Simple_linear_regression).
There are various options like optimize.leastsq and the OLS function at
http://www.scipy.org/Cookbook/OLS. Hopefully Skipper's GSoC work using
Jonathan Taylor's statistical models will provide a more general approach.
Does Sage have any particular needs for regression?
More information about the SciPy-user