# [SciPy-user] linear regression

josef.pktd@gmai... josef.pktd@gmai...
Wed May 27 13:28:00 CDT 2009

```On Wed, May 27, 2009 at 12:35 PM, ms <devicerandom@gmail.com> wrote:
> josef.pktd@gmail.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 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
squares.
A google search shows links to curve fitting but not to any
econometric theory. On the other hand, there is a very large
literature on how to treat measurement errors and endogeneity of
regressors for (standard) least squares and maximum likelihood.

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
curve.
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?

I also haven't spend the time yet to figure out what scipy.maxentropy
really does.

Josef
```