statsmodels.regression.linear_model.
OLS
statsmodels.stats.outliers_influence.
variance_inflation_factor
), has the default setting with no intercept while the latter one has the default setting with intercept. This creates a bit of confusion in the result as the result won't be the same if you use the VIF function and or use step-by-step calculation by using the statsmodel.ols.def vif_RG(exog, exog_idx):
import statsmodels.api as sm
k_vars = exog.shape[1]
x_i = exog[:, exog_idx]
mask = np.arange(k_vars) != exog_idx
x_noti = exog[:, mask]
x_noti = sm.add_constant(x_noti)
r_squared_i = sm.OLS(x_i, x_noti).fit().rsquared
#print(r_squared_i)
vif = 1. / (1. - r_squared_i)
return vif
Can you guys provide some feedback on this once you decide to change or take some actions about this?
Many thanks,
Alex
Many thanks,
Alex