Skip to content

ENH: Burgs algorithm - #5016

Merged
ChadFulton merged 6 commits into
statsmodels:masterfrom
bashtage:burgs-algorithm
Sep 1, 2018
Merged

ChadFulton merged 6 commits into
statsmodels:masterfrom
bashtage:burgs-algorithm

Conversation

@bashtage

Copy link
Copy Markdown
Member

Add Burg's algorithm as an alternative to Yule-Walker for PACF, AR, and ACF estimation.

@bashtage bashtage changed the title Burgs algorithm ENH: Burgs algorithm Aug 25, 2018
@coveralls

coveralls commented Aug 25, 2018 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.01%) to 83.961% when pulling 648d00e on bashtage:burgs-algorithm into a9bb76a on statsmodels:master.

@jbrockmendel

Copy link
Copy Markdown
Contributor

Based on a quick pass this looks good. Only question: why does burg belong in linearmodel. (I have the same question about yulewalker...)

@bashtage

bashtage commented Aug 25, 2018 via email

Copy link
Copy Markdown
Member Author

return np.array(pacf)


def pacf_burg(x, nlags=None, demean=True):

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.

This name (pacf_burg) has a different structure from levinson_durbin_pacf, but of course they do different things w.r.t. the pacf. Just wanted to check that this was desired.

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.

The most comparable is pacf_yw which has signature def pacf_yw(x, nlags=40, method='unbiased') vs def pacf_burg(x, nlags=None, demean=True):

There is no sense of alternative methods here so that parameter makes no sense. nlags=None is the future of acf/pacf estimations (I have another PR that fixes this), and then 10*log10(nobs).

As for levinson_durbin vs lebinson_durbin_pacf, the interpretation of x depending another input is IMO a mistake. It should have one job -- convert acovf to arcoefs (and other stuff). This makes it clear that the user can choose their preferred pacf estimator before running LD, and LD_pacf doesn't need to know about all of the pacf estimators available.



def pacf_burg(x, nlags=None, demean=True):
"""

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.

Perhaps a one-line description?

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.

Yes

Comment thread statsmodels/tsa/stattools.py Outdated
raise ValueError('nlags must be smaller than nobs - 1')
d = np.zeros(p + 1)
d[0] = 2 * x.dot(x)
phi = np.zeros(p + 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 don't know if we're still trying for descriptive naming, but could be arcoefs or something if we are.

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.

Good idea.

@ChadFulton

Copy link
Copy Markdown
Member

Looks like a nice addition to me. Couple of small comments.

Add Burg's method to compute the pacf
Add Burg's AR estimator
Add Levinson-Durbin for pacf->AR
Remove allocation of large matrices in Burg's pacf estimator
Add function that will convert pact to acf
Add Burg's method as ana alternatiive to Yule-Walker for pacf and AR estimation
Improve doc strings and variable names
@ChadFulton

Copy link
Copy Markdown
Member

Thanks! If you think it's ready to merge, I will do so tomorrow, unless there are concerns.

@codecov

codecov Bot commented Aug 30, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #5016 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5016      +/-   ##
==========================================
+ Coverage   81.45%   81.46%   +0.01%     
==========================================
  Files         582      582              
  Lines       90116    90246     +130     
  Branches    10093    10106      +13     
==========================================
+ Hits        73401    73522     +121     
- Misses      14416    14422       +6     
- Partials     2299     2302       +3
Impacted Files Coverage Δ
statsmodels/tsa/tests/test_stattools.py 98.59% <100%> (+0.17%) ⬆️
statsmodels/regression/linear_model.py 91.32% <100%> (+0.14%) ⬆️
statsmodels/tsa/stattools.py 86.3% <100%> (+1.65%) ⬆️
statsmodels/regression/tests/test_regression.py 99.62% <100%> (ø) ⬆️
statsmodels/regression/mixed_linear_model.py 88.97% <0%> (-0.8%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a9bb76a...648d00e. Read the comment docs.

Ensure all paths are tested
@ChadFulton

Copy link
Copy Markdown
Member

@bashtage ready for merge?

@bashtage

bashtage commented Sep 1, 2018

Copy link
Copy Markdown
Member Author

Yes

@ChadFulton
ChadFulton merged commit 50c7a5d into statsmodels:master Sep 1, 2018
@ChadFulton

Copy link
Copy Markdown
Member

Thanks @bashtage !

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants