Giter Site home page Giter Site logo

Comments (4)

wesm avatar wesm commented on May 22, 2024

[ LP comment 1 by: joep, on 2009-09-22 03:15:13.256575+00:00 ]

In a related issue, I am a bit puzzled why class Model defines self.exog as row vector if original exog is 1d

class Model
def init(self, endog, exog=None):
self.endog = np.asarray(endog)
self.exog = np.atleast_2d(np.asarray(exog))

I think in GLSAR.init, I used a (n,1) exog when I only have the constant:
if exog is None:
super(GLSAR, self).init(endog, np.ones((endog.shape[0],1)))

I guess we need tests to make sure every class works consistently with 1d row or column vectors as exog. Similarly, I'm not sure what the dimension requirements for endog are, 1d or also 2d column vector.

from statsmodels.

wesm avatar wesm commented on May 22, 2024

[ LP comment 2 by: joep, on 2009-09-22 19:15:31.916917+00:00 ]

res_regression = sm.OLS(res[1:],res[:1]).fit()

here exog has only a single element. It looks like we don't have a check for consistent number of observation in endog and exog.

sm.OLS(res[1:,None], res[:-1,None]).fit().params
array([[-0.36676742]])
sm.OLS(res[1:], res[:-1,None]).fit().params
array([-0.36676742])
sm.OLS(res[1:], res[:-1]).fit().params # 1d exog fails
Traceback (most recent call last):
...
ValueError: matrices are not aligned

But it looks like 1d exog fails,

from statsmodels.

wesm avatar wesm commented on May 22, 2024

[ LP comment 3 by: Skipper Seabold, on 2009-09-22 20:54:41.292465+00:00 ]

Good catch. That was a typo. Should be res[:,-1] I think (not on a machine where I can test).

Part of fixing this "bug" should be adding the checks for shapes. I would like the user to never have to worry about whether the shape is 1d or 2d ie., (N,) vs (N,1). Part of the inconsistency now is from pinv and dot not being able to distinguish between the two (though with good reason in this case). That way, it should be the first test that's written for new models. It's not clear right now how much can be moved up to the parent class wrt your comments on GLSAR.

from statsmodels.

wesm avatar wesm commented on May 22, 2024

[ LP comment 4 by: Skipper Seabold, on 2009-09-28 18:14:41.707427+00:00 ]

I have commited a fix for this and added some tests for shapes in regression to test_regression. It currently tests that the outputs are the same for the shapes of (n,1) or (n,) for endog or (n,1) or (n,) for exog. There is also test that endog.shape[0] = exog.shape[0]. Changes are in my branch only at the moment.

from statsmodels.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.