add_constant() in statsmodels not working add_constant() in statsmodels not working python-3.x python-3.x

add_constant() in statsmodels not working


It seems that add_constant() doesn't works if there is already a column with variance=0, i.e. a column with all identical values. It is the case in my dataset (not mentioned in the example above (54 columns)).

The solution is to add has_constant option in the add_constant() function, like this:

sm.add_constant(testmat[60], has_constant='add')

More information: http://www.statsmodels.org/dev/generated/statsmodels.tools.tools.add_constant.html