Skip to content

Commit

Permalink
Merge pull request #5684 from josef-pkt/bug_wald_test_terms_df_5475
Browse files Browse the repository at this point in the history
BUG: fix df in summary for single constraint in wald_test_terms
  • Loading branch information
bashtage committed May 16, 2019
2 parents 508a782 + b9c27d9 commit 7dff8c3
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
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
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 7dff8c3

Please sign in to comment.