Skip to content

SUMM: follow-up state space kalman filter merge #2252

Closed

Description

@josef-pkt

soon

  • specification dict should be a Bunch, IMO (I don't have tab completion for dict keys)
  • related to specification dict: _init_kwds for recreating model (generic, not used in tsa yet ?) PR WIP ENH/BUG: add update _init_keys (still test failure) #2259
  • unit tests for t_test, wald_test (use testing helper function) PR BUG: fix t_test wald_test requirements #2258
  • wrapper: I just saw this. MLEResults and SARIMAXResults do explicit wrapping of params and similar, instead of using the wrapper class as other models. e.g. res.params is pandas.Series, res._params is np array. ARIMA is using arima_model.ARMAResultsWrapper

it looks like there might be trailing whitespace, rebase didn't clean those up.
(my editor removed some whitespace in #2258)

later

design, possible refactoring

mostly undecided

  • *args, **kwds in loglike, score and similar, see comment below
  • minimize holding of "state" if it's not needed (remove from methods that don't require it)
  • memory layout, c or fortran contiguous, see todo and comments
  • single precision calculation: pretty large failure on Travis and most likely will also have problems on other machines, check or ignore (recommendation: Don't do that!)

Activity

  1. added this to the 0.7 milestone on Feb 12, 2015
  2. josef-pkt commented on Feb 12, 2015

    @josef-pkt
    MemberAuthor

    two details

    • I'm not able to run the skipped test with nosetests --no-skip. I don't know how this needs to be done.
    • for t_test, wald_test: to fix: define df_resid, delete mlemodel.MLEResults.cov_params to use inherited.

    I'm preparing a PR for t_test

  3. ChadFulton commented on Feb 12, 2015

    @ChadFulton
    Member

    Should I make individual issues for different TODO items, or group them here? Possibly the single-precision issue deserves its own issue since it will presumably be long-lived until someone has the motivation to investigate and fix it.

  4. josef-pkt commented on Feb 12, 2015

    @josef-pkt
    MemberAuthor

    I started SUMM issues as a table of content and for general discussion and overview. If there is more specific information (besides a few line summary), then we can open another issue. Also it's good to have separate issues that can be closed when we actually work on it, also for the record and easier searching for changes.
    (The biggest SUMM issue is cov_type which has lots of separate issues for specific implementation.)

  5. josef-pkt commented on Feb 12, 2015

    @josef-pkt
    MemberAuthor

    right now we don't need to open issues for things that we will fix right away.
    I have the t_test/wald_test fix almost ready. (but need to pick up now the kids from school)

  6. josef-pkt commented on Feb 13, 2015

    @josef-pkt
    MemberAuthor

    it looks like SARIMAXStatsmodelsTests are not run.
    nosetests <path to>/test_sarimax.py runs 305 tests
    if I change name to TestSARIMAXStatsmodels leading Tests in name, then I get 312 tests (including one I added)

    (found because: to verify that my test is run, I changed the numbers to cause a failure, but the failure never showed up.)

    edit maybe because my version of nose is old (I thought both leading and trailing test are used to identify test objects.)

  7. josef-pkt commented on Feb 13, 2015

    @josef-pkt
    MemberAuthor

    It took me a while to figure out how to calculate the right score to check convergence.

    _args and *_kwargs in loglike, score, and similar are different from other models.
    Do we want to refactor this at some point?
    (both have advantages and disadvantages, but having to distinguish transformed and untransformed as user is confusing.)

            nargs = len(args)
            if nargs < 1:
                kwargs.setdefault('average_loglike', True)
            if nargs < 2:
                kwargs.setdefault('transformed', False)
            if nargs < 3:
                kwargs.setdefault('set_params', False)
    

    I was checking the score at the optimum and got large numbers.
    no args and keyword transformed=True

    edit new issue for parameter transformation #2256

  8. josef-pkt commented on Feb 13, 2015

    @josef-pkt
    MemberAuthor

    @ChadFulton question on actually used number of observations:
    t_test, wald_test require a df_resid attribute even if it's not used.

    Is there a simple way to get the number of observations used in estimation, excluding for example the initial observations differenced away?

  9. ChadFulton commented on Feb 13, 2015

    @ChadFulton
    Member

    args and *kwargs in loglike, score, and similar are different from other models.
    Do we want to refactor this at some point?

    I agree, that would be a good idea, lets put it on the TODO list. I'm sure there's a better way to do it, but it's a part that I haven't looked at since I got it "working".

    Is there a simple way to get the number of observations used in estimation, excluding for example the initial observations differenced away?

    The way it works right now for SARIMAX is as follows:

    If simple_differencing=False, then all observations are used for estimation, and mod.nobs is accurate, even if there is an order-of-integration in the model. However, in that case, we typically ignore the likelihood for a number of periods equal to the order of integration. Should those count in a d.o.f. parameter? I don't know.

    If simple_differencing=True, then the actual mod.endog (and possibly mod.exog) arrays are replaced in the constructor with the differenced versions. So still, here, mod.nobs gives the true number of observations used in estimation. The original datasets are held in mod.orig_endog (and possibly mod.orig_exog).

  10. josef-pkt commented on Feb 14, 2015

    @josef-pkt
    MemberAuthor

    df_resid:
    For MLE in general, I would say the number of observations in loglike evaluation (len(loglike_obs))
    which in this case, given the change in endog, we would only have in one case n_ignores (?) to subtract from nobs. (or for simplicity we just stick with nobs.

  11. ChadFulton commented on Feb 15, 2015

    @ChadFulton
    Member

    A couple of miscellaneous things that need to be done:

    • Add unit tests for standardized_forecasts_error and kalman_gain
    • Cache (or do something about) foreign files in the notebooks
    • I renamed params_included to param_terms, but need to make it an OrderedDict
  12. ChadFulton commented on Feb 18, 2015

    @ChadFulton
    Member

    Two new miscellaneous issues that came up:

    • exog_names breaks on Pandas objects in SARIMAX
    • Adding self.data.param_names = self.param_names to the MLEModel constructor causes ad-hoc models to fail since the names then aren't specified at construction time.

    I will have PRs that fix them in a moment.

  13. ChadFulton commented on Jun 29, 2015

    @ChadFulton
    Member

    I'm hoping to revisit this issue / the plan for state space models in 0.7.

    The following PRs / issues are currently open (see also #2467):


    The only PR that I suppose must be in 0.7 is #2461, fixing the standardized forecast errors. However, here is what I propose.

    1. Review / merge bug fixes: COMPAT/TST: Statespace: Standardized residuals: fix compatibility with Scipy 0.11, add tests #2461(fix the standardized forecast errors bug)
    2. Review / merge simple PRs: ENH: Make SARIMAXResults.specification a Bunch #2489 (dict -> Bunch), ENH: Add initialization via keyword args to init. #2488 (initialization in init kwargs)
    3. Review / merge ENH: Statespace - add OIM and OPG covariance matrices #2356: add covariance matrix improvements

    So far these should be relatively easy to review and merge. Only #2356 has any substantial changes.

    Now, there are two design decisions in the list above, and it seems to me that they should be addressed prior to 0.7, so that we don't immediately introduce relatively big changes in 0.8:

    1. Decide whether or not to include ad-hoc models (see Design: Ad hoc state space models #2330). My current thought is that they should not be supported in the base MLEModel class, even if we add them later in a subclass (e.g. AdHocModel or whatever). If we do decide to drop them, that is addressed in ENH: Decouple state space / filter from MLE #2473.
    2. Review / discuss / merge ENH: Decouple state space / filter from MLE #2473: decouple MLE from state space. My feeling is that the PR is actually pretty straightforward, and doesn't have any particularly challenging questions that need to be addressed, although there are probably some changes that would need to be made.

    If we did all of these things, then in addition to the things mentioned above, the various PRs will also give us the following:

    • _init_kwds for recreating model should be fully consistent with base models (no need to issue a warning in SARIMAX for alternate initializations or put endog and exog in the _init_kwds dict).
    • Wrapper classes will be used for the Results classes.
    • cov_type will be allowed, along with good estimation methods (opg and oim) and a robust / QMLE option
    • *args has already been removed from everywhere feasible, and **kwargs has been pared down where possible and documented elsewhere.
  14. ChadFulton commented on Jun 29, 2015

    @ChadFulton
    Member

    Finally, the remaining PRs:

    could wait until 0.8.

  15. josef-pkt commented on Jun 30, 2015

    @josef-pkt
    MemberAuthor

    @ChadFulton Thanks for the summary and update

    I'll try to go over it tomorrow. I agree that we should merge the fixes since this hasn't been released yet, and we want to get some of the refactoring before the release.
    (I was hoping to start merging 0.8 PRs, but it might not happen before I fly to Europe next weekend.)

  16. josef-pkt commented on Jun 30, 2015

    @josef-pkt
    MemberAuthor

    the first three are easy to merge #2461 #2489 #2488 rebasing is mainly cosmetic

    I will go over cov_type #2356 during the next few hours,

  17. josef-pkt commented on Jul 4, 2015

    @josef-pkt
    MemberAuthor

    #2356 is also merged

    #2330 ad hoc models: I read the discussion again. I think we shouldn't allow them, or at least not advertise them and discourage their use until further notice.
    We can leave some refactoring for 0.8. It will be the first release with statespace and I expect that we get some feedback, and assume we will still have ongoing "maturing" during 0.8 and will get additional experience based on the additional models coming in with the GSOC project.

    #2473 This is mostly internal, and I don't have time or I'm too impatient right now to review this. I will merge it based on your recommendation.
    Because test coverage is pretty good and you have several models on top of it, I guess mergin it should be pretty safe. However, I guess it won't affect endusers much and will affect mainly developers, so merging it for 0.7 or right after tagging for 0.8 won't make much difference.

    I also assume we want to merge it very soon, so you can rebase the new models on top of it.

    Lot's of guesses based on insufficient review. (I need to go pack my suitcase :)

  18. josef-pkt commented on Jul 4, 2015

    @josef-pkt
    MemberAuthor

    @ChadFulton One more for 0.7: Can you check whether the release notes need an update, and open a PR if necessary? Thanks

  19. ChadFulton commented on Feb 12, 2016

    @ChadFulton
    Member

    I think everything discussed in this issue has been resolved / merged. We could probably close, unless it's handy to keep open for some reason.

  20. josef-pkt commented on Feb 12, 2016

    @josef-pkt
    MemberAuthor

    I read through this again. There might be some details left to look at, but this is pretty much done.

    So closing. We can still find it as reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions