Skip to content

Commit

Permalink
Add failing test t_est_missing_formula
Browse files Browse the repository at this point in the history
  • Loading branch information
kshedden authored and josef-pkt committed Aug 20, 2014
1 parent f05bdfb commit 993e523
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions statsmodels/genmod/tests/test_gee.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,39 @@ def test_missing(self):
assert_almost_equal(rslt1.params, rslt2.params)
assert_almost_equal(rslt1.bse, rslt2.bse)

def t_est_missing_formula(self):
"""
Test missing data handling for formulas.
"""

endog = np.random.normal(size=100)
exog1 = np.random.normal(size=100)
exog2 = np.random.normal(size=100)
exog3 = np.random.normal(size=100)
groups = np.kron(lrange(20), np.ones(5))

endog[0] = np.nan
endog[5:7] = np.nan
exog2[10:12] = np.nan

data = pd.DataFrame({"endog": endog, "exog1": exog1, "exog2": exog2,
"exog3": exog3, "groups": groups})

mod1 = GEE.from_formula("endog ~ exog1 + exog2 + exog3",
groups, data, missing='drop')
rslt1 = mod1.fit()

assert_almost_equal(len(mod1.endog), 95)
assert_almost_equal(np.asarray(mod1.exog.shape), np.r_[95, 3])

data = data.dropna()

mod2 = GEE.from_formula("endog ~ exog1 + exog2 + exog3",
groups, data, missing='none')
rslt2 = mod2.fit()

assert_almost_equal(rslt1.params, rslt2.params)
assert_almost_equal(rslt1.bse, rslt2.bse)

def test_default_time(self):
"""
Expand Down

0 comments on commit 993e523

Please sign in to comment.