Repository: statsmodels/statsmodels

Issue:
CompareMeans.summary() doesn't seem to work
```
from statsmodels.stats.weightstats import CompareMeans, DescrStatsW
import numpy as np
a = np.array([2,3,4,5,6])
b = np.array([1,2,3,4,5])
CompareMeans(DescrStatsW(a), DescrStatsW(b)).summary()
```
This returns an error. To be more specific, an IndexError:
```
/home/home/anaconda3/lib/python3.6/site-packages/statsmodels/iolib/summary.py in <listcomp>(.0)
    468     exog_idx = lrange(len(xname))
    469 
--> 470     params_data = lzip([forg(params[i], prec=4) for i in exog_idx],
    471                        [forg(std_err[i]) for i in exog_idx],
    472                        [forg(tvalues[i]) for i in exog_idx],

IndexError: invalid index to scalar variable.
```


Discussion:
It looks like there is an implicit assumption for 2d arrays.
Using column vectors works for me

```
from statsmodels.stats.weightstats import CompareMeans, DescrStatsW
import numpy as np
a = np.array([2,3,4,5,6])[:, None]
b = np.array([1,2,3,4,5])[:, None]
print(CompareMeans(DescrStatsW(a), DescrStatsW(b)).summary())
```
```
                          Test for equality of means                          
==============================================================================
                 coef    std err          t      P>|t|      [0.025      0.975]
------------------------------------------------------------------------------
subset #1      1.0000      1.000      1.000      0.347      -1.306       3.306
==============================================================================>
```

That's a bug, Thanks for reporting.

It looks like all others than params have np.atleast_1d, but it was left out from params.


Resolving patch:
diff --git a/statsmodels/stats/weightstats.py b/statsmodels/stats/weightstats.py
--- a/statsmodels/stats/weightstats.py
+++ b/statsmodels/stats/weightstats.py
@@ -803,7 +803,7 @@ def summary(self, use_t=True, alpha=0.05, usevar='pooled', value=0):
         lower = np.atleast_1d(lower)
         upper = np.atleast_1d(upper)
         conf_int = np.column_stack((lower, upper))
-        params = d1.mean - d2.mean - value
+        params = np.atleast_1d(d1.mean - d2.mean - value)
         
         title = 'Test for equality of means'
         yname = 'y' # not used in params_frame


Test patch:
diff --git a/statsmodels/stats/tests/test_weightstats.py b/statsmodels/stats/tests/test_weightstats.py
--- a/statsmodels/stats/tests/test_weightstats.py
+++ b/statsmodels/stats/tests/test_weightstats.py
@@ -318,6 +318,24 @@ def test_comparemeans_convenient_interface(self):
         cm2 = CompareMeans.from_data(x1_2d, x2_2d)
         assert_(str(cm1.summary()) == str(cm2.summary()))
 
+    def test_comparemeans_convenient_interface_1d(self):
+        # same as above for 2d, just use 1d data instead
+        x1_2d, x2_2d = self.x1, self.x2
+        d1 = DescrStatsW(x1_2d)
+        d2 = DescrStatsW(x2_2d)
+        cm1 = CompareMeans(d1, d2)
+
+        # smoke test for summary
+        from statsmodels.iolib.table import SimpleTable
+        for use_t in [True, False]:
+            for usevar in ['pooled', 'unequal']:
+                smry = cm1.summary(use_t=use_t, usevar=usevar)
+                assert_(isinstance(smry, SimpleTable))
+
+        # test for from_data method
+        cm2 = CompareMeans.from_data(x1_2d, x2_2d)
+        assert_(str(cm1.summary()) == str(cm2.summary()))
+
 
 class CheckWeightstats1dMixin(object):