Skip to content

Commit f525818

Browse files
committed
BUG/ENH: fix base t_test, wald_test, closes statsmodels#8905
1 parent 77cb066 commit f525818

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

statsmodels/base/model.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,11 @@ def t_test(self, r_matrix, cov_p=None, use_t=None):
16391639
"""
16401640
from patsy import DesignInfo
16411641
use_t = bool_like(use_t, "use_t", strict=True, optional=True)
1642-
names = self.model.data.cov_names
1642+
if self.params.ndim == 2:
1643+
names = ['y{}_{}'.format(i[0], i[1])
1644+
for i in self.model.data.cov_names]
1645+
else:
1646+
names = self.model.data.cov_names
16431647
LC = DesignInfo(names).linear_constraint(r_matrix)
16441648
r_matrix, q_matrix = LC.coefs, LC.constants
16451649
num_ttests = r_matrix.shape[0]
@@ -1649,7 +1653,7 @@ def t_test(self, r_matrix, cov_p=None, use_t=None):
16491653
not hasattr(self, 'cov_params_default')):
16501654
raise ValueError('Need covariance of parameters for computing '
16511655
'T statistics')
1652-
params = self.params.ravel()
1656+
params = self.params.ravel(order="F")
16531657
if num_params != params.shape[0]:
16541658
raise ValueError('r_matrix and params are not aligned')
16551659
if q_matrix is None:
@@ -1853,8 +1857,12 @@ def wald_test(self, r_matrix, cov_p=None, invcov=None,
18531857
use_f = (hasattr(self, 'use_t') and self.use_t)
18541858

18551859
from patsy import DesignInfo
1856-
names = self.model.data.cov_names
1857-
params = self.params.ravel()
1860+
if self.params.ndim == 2:
1861+
names = ['y{}_{}'.format(i[0], i[1])
1862+
for i in self.model.data.cov_names]
1863+
else:
1864+
names = self.model.data.cov_names
1865+
params = self.params.ravel(order="F")
18581866
LC = DesignInfo(names).linear_constraint(r_matrix)
18591867
r_matrix, q_matrix = LC.coefs, LC.constants
18601868

0 commit comments

Comments
 (0)