bashtage/linearmodels

Option to avoid MissingValueWarning warning.

marcdelabarrera opened this issue · 3 comments

Currently, it seems there is no way to avoid the MissingValueWarning when initializing a IV2SLS (and I guess any parent of it). It would be nice to have the option to avoid this warning, since if one uses operators like shift, it inevitably induces missing values in the formula. I know it and I want them to be dropped.

The current solution is:

import warnings
from linearmodels.shared.exceptions import MissingValueWarning
warnings.filterwarnings("ignore", category=MissingValueWarning)

but it would be nice to have a missing option like statsmodels OLS.

I think the only practical way to disable this would require an options structure similar to what pandas does. Something like

from linear models import options, options_manager

# Permanent, until switched
options.warn_on_missing = False
# or, temporarily
with options_manager(warn_on_missing=False):
   PanelOLS(...)

Alternatively, you could call dropna on your DataFrame.

Thx. dropna in the DataFrame does not work if I use .shift() in the formula since it introduces na values even with a dataset without na. the options make sense and I don't have to use warnings. It would be great to have it as an option when creating the instance IV2SLS.