Skip to content

BUG/TST: Fix innovations_filter, add test vs Kalman filter - #5325

Merged
ChadFulton merged 5 commits into
statsmodels:masterfrom
ChadFulton:innovations
Oct 24, 2018
Merged

ChadFulton merged 5 commits into
statsmodels:masterfrom
ChadFulton:innovations

Conversation

@ChadFulton

Copy link
Copy Markdown
Member

This fixes two bugs in tsa.stattools.innovation_filter and adds a more comprehensive unit test versus Kalman filter output.

@bashtage would be happy for your thoughts.

@ChadFulton ChadFulton added comp-tsa type-bug-wrong serious bugs that silently return incorrect numbers labels Oct 17, 2018
if not isinstance(rtol, float):
raise ValueError('rtol must be a non-negative float or None.')
n = acov.shape[0] if nobs is None else int(nobs)
if n != nobs or nobs < 1:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to change this, since n != nobs is always true if nobs is not explicitly set.

else:
hat = (theta[i] * u[i - k:i][::-1]).sum()
u[i] = endog[i] + hat
u[i] = endog[i] - hat

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look right. Surprised I missed that

expected = [endog[0]]
for i in range(1, 4):
expected.append(endog[i] + theta[i, 0] * expected[-1])
expected.append(endog[i] - theta[i, 0] * expected[-1])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess repeating the same typo is how

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

@ChadFulton

Copy link
Copy Markdown
Member Author

One other question before I merge this - the general innovations algorithm in Brockwell and Davis allows for non-stationary input - i.e. where covariances change over time, but if I'm reading the function right, I guess it assumes that the process is stationary?

If so I guess we should add that to the documentation.

@ChadFulton

Copy link
Copy Markdown
Member Author

Well I'll merge this now, and we can improve the documentation later if necessary.

@ChadFulton
ChadFulton merged commit 34ae057 into statsmodels:master Oct 24, 2018
@ChadFulton
ChadFulton deleted the innovations branch October 24, 2018 23:42
@josef-pkt josef-pkt added this to the 0.10 milestone Dec 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-tsa type-bug-wrong serious bugs that silently return incorrect numbers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants