You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SUMM: follow-up state space kalman filter merge #2252
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)
*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!)
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.
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.)
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)
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.)
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
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).
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.
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.
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:
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.
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.)
#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 :)
Activity
josef-pkt commentedon Feb 12, 2015
two details
nosetests --no-skip. I don't know how this needs to be done.df_resid, deletemlemodel.MLEResults.cov_paramsto use inherited.I'm preparing a PR for t_test
ChadFulton commentedon Feb 12, 2015
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.
josef-pkt commentedon Feb 12, 2015
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.)
josef-pkt commentedon Feb 12, 2015
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)
josef-pkt commentedon Feb 13, 2015
it looks like
SARIMAXStatsmodelsTestsare not run.nosetests <path to>/test_sarimax.pyruns 305 testsif I change name to
TestSARIMAXStatsmodelsleadingTestsin 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.)
josef-pkt commentedon Feb 13, 2015
It took me a while to figure out how to calculate the right
scoreto 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.)
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
josef-pkt commentedon Feb 13, 2015
@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?
ChadFulton commentedon Feb 13, 2015
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".
The way it works right now for SARIMAX is as follows:
If
simple_differencing=False, then all observations are used for estimation, andmod.nobsis 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 actualmod.endog(and possiblymod.exog) arrays are replaced in the constructor with the differenced versions. So still, here,mod.nobsgives the true number of observations used in estimation. The original datasets are held inmod.orig_endog(and possiblymod.orig_exog).josef-pkt commentedon Feb 14, 2015
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 casen_ignores(?) to subtract from nobs. (or for simplicity we just stick with nobs.ChadFulton commentedon Feb 15, 2015
A couple of miscellaneous things that need to be done:
standardized_forecasts_errorandkalman_gainparams_includedtoparam_terms, but need to make it an OrderedDictChadFulton commentedon Feb 18, 2015
Two new miscellaneous issues that came up:
exog_namesbreaks on Pandas objects in SARIMAXself.data.param_names = self.param_namesto 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.
ChadFulton commentedon Jun 29, 2015
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):
cov_typeto MLEModel results, improve standard errorsstandardized_forecasts_errorhad a bug with Scipy 0.11The only PR that I suppose must be in 0.7 is #2461, fixing the standardized forecast errors. However, here is what I propose.
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:
MLEModelclass, even if we add them later in a subclass (e.g.AdHocModelor whatever). If we do decide to drop them, that is addressed in ENH: Decouple state space / filter from MLE #2473.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_kwdsfor 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_kwdsdict).cov_typewill be allowed, along with good estimation methods (opgandoim) and a robust / QMLE option*argshas already been removed from everywhere feasible, and**kwargshas been pared down where possible and documented elsewhere.ChadFulton commentedon Jun 29, 2015
Finally, the remaining PRs:
could wait until 0.8.
josef-pkt commentedon Jun 30, 2015
@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.)
josef-pkt commentedon Jun 30, 2015
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,
josef-pkt commentedon Jul 4, 2015
#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
statespaceand 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 :)
josef-pkt commentedon Jul 4, 2015
@ChadFulton One more for 0.7: Can you check whether the release notes need an update, and open a PR if necessary? Thanks
ChadFulton commentedon Feb 12, 2016
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.
josef-pkt commentedon Feb 12, 2016
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.