Statsmodel multivariate OLS error "matrices are not aligned"
Question: I am trying to solve multivariate regression. Here is the code attached for
the regression. The model builds fine, but when I try to retrieve the summary,
it gives following error

**ValueError: matrices are not aligned**

Here is the traceback:

    
    
    Traceback (most recent call last):
    File "/Users/mikhilraj/Desktop/try2.py", line 23, in <module>
        print mod.summary()
    File "/Library/Python/2.7/site-packages/statsmodels-0.7.0-py2.7-macosx-10.10-intel.egg/statsmodels/regression/linear_model.py", line 1967, in summary
        top_right = [('R-squared:', ["%#8.3f" % self.rsquared]),
    File "/Library/Python/2.7/site-packages/statsmodels-0.7.0-py2.7-macosx-10.10-intel.egg/statsmodels/tools/decorators.py", line 97, in __get__
        _cachedval = self.fget(obj)
    File "/Library/Python/2.7/site-packages/statsmodels-0.7.0-py2.7-macosx-10.10-intel.egg/statsmodels/regression/linear_model.py", line 1181, in rsquared
        return 1 - self.ssr/self.centered_tss
    File "/Library/Python/2.7/site-packages/statsmodels-0.7.0-py2.7-macosx-10.10-intel.egg/statsmodels/tools/decorators.py", line 97, in __get__
        _cachedval = self.fget(obj)
    File "/Library/Python/2.7/site-packages/statsmodels-0.7.0-py2.7-macosx-10.10-intel.egg/statsmodels/regression/linear_model.py", line 1153, in ssr
        return np.dot(wresid, wresid)
    ValueError: matrices are not aligned
    

**Code:**

    
    
    import numpy as np
    import statsmodels.api as sm
    
    
    np.random.seed(12345)
    
    N = 30
    
    X = np.random.uniform(-20, 20, size=(N,10))
    beta = np.random.randn(11)
    X = sm.add_constant(X)
    
    
    weights = np.random.uniform(1, 20, size=(N,))
    weights = weights/weights.sum()
    
    y = np.dot(X, beta) + weights*np.random.uniform(-100, 100, size=(N,))
    
    Y = np.c_[y,y,y]
    
    mod = sm.OLS(Y, X).fit()
    
    print mod.summary()
    


Answer: The `endog` parameter should be a 1D vector of the dependent variable.
Changing the parameter `Y` in your model to `y` (for example) allows the code
to run without error.

<http://statsmodels.sourceforge.net/devel/generated/statsmodels.regression.linear_model.OLS.html>

