Ejemplo n.º 1
0
 def _drop_missing(self) -> BoolArray:
     data = (self.portfolios, self.factors)
     missing = cast(BoolArray, np.any(np.c_[[dh.isnull for dh in data]], 0))
     if any(missing):
         if all(missing):
             raise ValueError("All observations contain missing data. "
                              "Model cannot be estimated.")
         self.portfolios.drop(missing)
         self.factors.drop(missing)
     missing_warning(missing)
     return missing
Ejemplo n.º 2
0
 def _drop_missing(self) -> BoolArray:
     missing = self.dependent.isnull.to_numpy()
     missing |= self.exog.isnull.to_numpy()
     missing |= self._absorb_inter.cat.isnull().any(1).to_numpy()
     missing |= self._absorb_inter.cont.isnull().any(1).to_numpy()
     for interact in self._interaction_list:
         missing |= interact.isnull.to_numpy()
     if npany(missing):
         self.dependent.drop(missing)
         self.exog.drop(missing)
         self._absorb_inter.drop(missing)
         for interact in self._interaction_list:
             interact.drop(missing)
     missing_warning(missing)
     return missing
Ejemplo n.º 3
0
def test_missing_warning():
    missing = np.zeros(500, dtype=bool)
    with warnings.catch_warnings(record=True) as w:
        missing_warning(missing)
        assert len(w) == 0

    missing[0] = True
    with warnings.catch_warnings(record=True) as w:
        missing_warning(missing)
        assert len(w) == 1

    original = linearmodels.WARN_ON_MISSING
    linearmodels.WARN_ON_MISSING = False
    with warnings.catch_warnings(record=True) as w:
        missing_warning(missing)
        assert len(w) == 0
    linearmodels.WARN_ON_MISSING = original