[SciPy-user] linear regression
Wed May 27 14:00:25 CDT 2009
email@example.com ha scritto:
> On Wed, May 27, 2009 at 12:35 PM, ms <firstname.lastname@example.org> wrote:
>> email@example.com ha scritto:
>>>> Have a look here <http://www.scipy.org/Cookbook/LinearRegression>
>>> y = Beta0 + Beta1 * x + Beta2 * x**2 is the second order polynomial.
>>> I also should have looked, polyfit returns the polynomial coefficients
>>> but doesn't calculate the variance-covariance matrix or standard
>>> errors of the OLS estimate.
>> AFAIK, the ODR fitting routines return all these parameters, so one can
>> maybe use that for linear fitting too.
> you mean scipy.odr?
I use it for non-linear fitting, and it gives parameters, standard
deviations and covariance matrix.
> I never looked at it in details. Conceptionally it is very similar to
> standard regression, but I've never seen an application for it, nor do
> I know the probability theoretic or econometric background of it. The
> results for many cases will be relatively close to standard least
You can explicitly tell the odr function to use least squares fitting.
> A google search shows links to curve fitting but not to any
> econometric theory.
The math of fitting data to a function, as far as I know, is independent
of the field of application. The functions and the data, of course, are
> The difference between curve fitting and (maybe prediction) and
> parameter estimation in many social/economic sciences is that we want
> to get a reliable parameter estimate and not just a well fitting
Ehm, I don't know what is your knowledge of sciences, but trust me, no
one does curve fitting only to obtain "a well fitting curve": everyone
wants parameters, obviously, and their statistics.
scipy.odr gives me these nicely.
> How much does the average lifetime income increase when finishing
> college compared to only finishing high school? Did the price of oil
> go up because of demand side or supply side effects? Did the
> availability of contraceptives decrease crime?
On a side note, you won't answer these interesting questions with linear
fitting only, because correlation does not mean causation.
More information about the SciPy-user