[SciPy-user] Multivariate regression?

Matthew Brett matthew.brett at gmail.com
Sat Oct 6 13:34:23 EDT 2007


Hi,

> > I study econometrics and statistics, and i wanted to try out my
> > favourite programming as a scientific tool. Unfortunately, I could not
> > find a function for ordinary least squares estimation. The
> > stats.linregress() is insufficient for my needs, and stats.glm() seems
> > to be for something else (not sure really).

I think you may want the OLS model in scipy.stats.models:

import numpy as N
import scipy.stats.models as SSM

covariates = N.random.normal(size=(100,3))
intercept = N.ones((100,1))
design = N.c_[covariates, intercept]
data = N.random.normal(size=(100,1))

model = SSM.regression.ols_model(design)
results = model.fit(data)

results.beta

The models package is still being developed, but it already does the
basic stuff,

Best,

Matthew



More information about the SciPy-User mailing list