Skip to content

Commit

Permalink
BUG: fix df in summary for single constraint in wald_test_terms closes
Browse files Browse the repository at this point in the history
  • Loading branch information
josef-pkt committed May 10, 2019
1 parent 8ec8124 commit b9c27d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion statsmodels/base/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,7 @@ def wald_test_terms(self, skip_single=False, extra_constraints=None,
else:
# check by exog/params names if there is no formula info
for col, name in enumerate(result.model.exog_names):
constraint_matrix = identity[col]
constraint_matrix = np.atleast_2d(identity[col])

# check if in combined
for cname in combine_terms:
Expand Down
12 changes: 10 additions & 2 deletions statsmodels/base/tests/test_generic_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,18 +531,26 @@ def initialize(cls):
cls.res = mod.fit(use_t=False)

def test_noformula(self):
# this verifies single and composite constraints against explicit
# wald test
endog = self.res.model.endog
exog = self.res.model.data.orig_exog
exog = pd.DataFrame(exog)

res = sm.OLS(endog, exog).fit()
wa = res.wald_test_terms(skip_single=True,
wa = res.wald_test_terms(skip_single=False,
combine_terms=['Duration', 'Weight'])
eye = np.eye(len(res.params))

c_single = [row for row in eye]
c_weight = eye[2:6]
c_duration = eye[[1, 4, 5]]

compare_waldres(res, wa, [c_duration, c_weight])
compare_waldres(res, wa, c_single + [c_duration, c_weight])

# assert correct df_constraints, see #5475 for bug in single constraint
df_constraints = [1] * len(c_single) + [3, 4]
assert_equal(wa.df_constraints, df_constraints)


class TestWaldAnovaOLSF(CheckAnovaMixin):
Expand Down

0 comments on commit b9c27d9

Please sign in to comment.