Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I zero the intercept in a multivariate regression using python?

Is it possible in python/scipy/numpy to zero the intercept of a multivariate regression? I couldn't find it in the OLS recipe (http://www.scipy.org/Cookbook/OLS).

I'd prefer not to have to use RPython but is that the only way?

like image 216
FinDev Avatar asked Dec 10 '25 01:12

FinDev


1 Answers

http://statsmodels.sourceforge.net/stable/generated/statsmodels.regression.linear_model.OLS.html

statsmodels requires you to create your designmatrix, called exog, that does not automatically add a constant/intercept. So, using statsmodels you can just leave out the constant and run your regression.

Some test or result statistic might not be correct in this case, since they assume that a constant is included, for example r_squared, if I remember correctly.

like image 105
Josef Avatar answered Dec 12 '25 18:12

Josef



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!