Repository: statsmodels/statsmodels

Issue:
BUG: t-test summary confidence interval range always shows [0.025      0.975]
Regardless of the given alpha, printed confidence interval range in t_test summary is [0.025      0.975], although the actual confidence interval itself does change appropriately.

Given:

``` python
np.random.seed(1234)
endog, exog = np.random.normal(size=(2, 100))
res = sm.OLS(endog, exog).fit()
test_res = res.t_test('x1 = 0')
```

then

``` python
print(test_res.summary(alpha=0.05))
```

produces:

```
                             Test for Constraints                             
==============================================================================
                 coef    std err          t      P>|t|      [0.025      0.975]
------------------------------------------------------------------------------
c0             0.0822      0.102      0.807      0.421      -0.120       0.284
==============================================================================
```

but:

``` python
print(test_res.summary(alpha=0.482))
```

produces:

```
                             Test for Constraints                             
==============================================================================
                 coef    std err          t      P>|t|      [0.025      0.975]
------------------------------------------------------------------------------
c0             0.0822      0.102      0.807      0.421       0.010       0.154
==============================================================================
```



Discussion:
Presumably in `contrast.py:L148` the call to `summary_params` needs to have the `alpha` argument:

``` python
summ = summary_params((self, self.effect, self.sd, self.statistic,
                                   pvalues, self.conf_int(alpha)),
                                  yname=yname, xname=xname, use_t=use_t,
                                  title=title)
```

Yes, `summary_params` and `summary_params_frame` have an `alpha` keyword which was left out.

summary_params_frame doesn't use alpha in the column names, name is generic
`'Conf. Int. Low', 'Conf. Int. Upp.'`


Resolving patch:
diff --git a/statsmodels/stats/contrast.py b/statsmodels/stats/contrast.py
--- a/statsmodels/stats/contrast.py
+++ b/statsmodels/stats/contrast.py
@@ -148,7 +148,7 @@ def summary(self, xname=None, alpha=0.05, title=None):
             summ = summary_params((self, self.effect, self.sd, self.statistic,
                                    pvalues, self.conf_int(alpha)),
                                   yname=yname, xname=xname, use_t=use_t,
-                                  title=title)
+                                  title=title, alpha=alpha)
             return summ
         elif hasattr(self, 'fvalue'):
             # TODO: create something nicer for these casee
@@ -175,7 +175,8 @@ def summary_frame(self, xname=None, alpha=0.05):
             summ = summary_params_frame((self, self.effect, self.sd,
                                          self.statistic,self.pvalue,
                                          self.conf_int(alpha)), yname=yname,
-                                         xname=xname, use_t=use_t)
+                                         xname=xname, use_t=use_t,
+                                         alpha=alpha)
             return summ
         else:
             # TODO: create something nicer


Test patch:
diff --git a/statsmodels/base/tests/test_generic_methods.py b/statsmodels/base/tests/test_generic_methods.py
--- a/statsmodels/base/tests/test_generic_methods.py
+++ b/statsmodels/base/tests/test_generic_methods.py
@@ -15,7 +15,8 @@
 import statsmodels.api as sm
 from statsmodels.compat.scipy import NumpyVersion
 
-from numpy.testing import assert_, assert_allclose, assert_equal
+from numpy.testing import (assert_, assert_allclose, assert_equal,
+                           assert_array_equal)
 
 from nose import SkipTest
 import platform
@@ -67,8 +68,21 @@ def test_ttest_tvalues(self):
         assert_(hasattr(res, 'use_t'))
 
         tt = res.t_test(mat[0])
-        tt.summary()   # smoke test for #1323
+        string_confint = lambda alpha: "[%4.3F      %4.3F]" % (
+                                       alpha / 2, 1- alpha / 2)
+        summ = tt.summary()   # smoke test for #1323
         assert_allclose(tt.pvalue, res.pvalues[0], rtol=5e-10)
+        assert_(string_confint(0.05) in str(summ))
+        # issue #3116 alpha not used in column headers
+        summ = tt.summary(alpha=0.1)
+        ss = "[0.05       0.95]"   # different formatting
+        assert_(ss in str(summ))
+        summf = tt.summary_frame(alpha=0.1)
+        pvstring_use_t = 'P>|z|' if res.use_t is False else 'P>|t|'
+        tstring_use_t = 'z' if res.use_t is False else 't'
+        cols = ['coef', 'std err', tstring_use_t, pvstring_use_t,
+                'Conf. Int. Low', 'Conf. Int. Upp.']
+        assert_array_equal(summf.columns.values, cols)
 
 
     def test_ftest_pvalues(self):