I'm trying to do 2 stage least squares regression in python using the statsmodels
library:
from statsmodels.sandbox.regression.gmm import IV2SLS
resultIV = IV2SLS(dietdummy['Log Income'],
dietdummy.drop(['Log Income', 'Diabetes']),
dietdummy.drop(['Log Income', 'Reads Nutri')
Reads Nutri
is my endogenous variable my instrument is Diabetes
and my dependent variable is Log Income
.
Did I do this right? It is much different than the way I would do it on Stata.
Also, when I do resultIV.summary()
, I get a TypeError
(something to do with the F statistic being nonetype). How can I resolve this?