HI, I'm new to python and the statsmodels library. Currently Im trying to replicate a project I did for my econometrics class (in which I used stata) with the statsmodels library. I have a problem when Im calculating the VIF with the statsmodels.stats.outliers_influence.variance_inflation_factor method, since the results arent the same nor slightly equal to the ones obtained by stata. The code I used is presented below, the variable vifResults stores the vif using the statsmodels method which is the one that diverge from the one calculated by stata and the vif variable calculates it in a "rudimentary" way, being this method the most accurate.
vif_stata = 2.49
vifResults = 1.51828167883
vif = 2.48617180511
import statsmodels.stats.outliers_influence as oi
#vif using the statsmodels method
vifResults = oi.variance_inflation_factor(vifVar.as_matrix(), i)
#vif using the OSL rsquared
vif = 1/(1 - sm.ols(formula='formula', data=vifVar).fit().rsquared)
I also want to mention that is not an index problem, by this I mean that the formula in the osl parameter is consistent with the index 'i' in the variance_inflation_factor.
I want to apologize for my english since is not my first language and I appreciate any help that can shed some light on why im getting different values.