Skip to content

BUG: Set default lags for acf/pacf plots - #4949

Merged
josef-pkt merged 1 commit into
statsmodels:masterfrom
bashtage:default-lags-acf-pacf-plots
Sep 10, 2018
Merged

josef-pkt merged 1 commit into
statsmodels:masterfrom
bashtage:default-lags-acf-pacf-plots

Conversation

@bashtage

Copy link
Copy Markdown
Member

Set a sensible default value for acf and pacf plot lags when not provided
using a method common to R based on the log of the number of observations.

closes #4663

@bashtage

Copy link
Copy Markdown
Member Author

Log is a sensible choice since it is probably maximum rate with which standard confidence regions are plausible.

@bashtage

Copy link
Copy Markdown
Member Author

closes #4748

@bashtage
bashtage force-pushed the default-lags-acf-pacf-plots branch from 4934db8 to 75725cd Compare August 21, 2018 11:52
acf_x = acf_x[1:]
lags = lags.astype(np.float)
lags[0] -= 0.5
lags[-1] += 0.5

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.

what's the reason for this?
Doesn't this keep the fill_between too far away from the plot left and right edges?

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.

Nope, it fills right to the point and so 1/2 the dot is outside the CI on the edges.

This is from master:

image

Comment thread statsmodels/graphics/tsaplots.py Outdated
# GH 4663 - use a sensible default value
nobs = x.shape[0]
lim = min(int(np.ceil(10 * np.log10(nobs))), nobs-1)
lim = lim if lim <= nobs - 1 else nobs - 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.

isn't this redundant with the previous line?

pep-8 missing spaces in nobs-1 on previous line

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.

still open question, I don't see what line 18 is supposed to do

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.

Not needed

@josef-pkt

Copy link
Copy Markdown
Member

LGTM, I don't have any clear opinion about the default, so following R is sensible.

@coveralls

coveralls commented Aug 21, 2018 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.03%) to 83.902% when pulling 47e410f on bashtage:default-lags-acf-pacf-plots into 38aa065 on statsmodels:master.

@bashtage
bashtage force-pushed the default-lags-acf-pacf-plots branch from 2e9b4cd to 14e41f0 Compare August 23, 2018 17:33
@codecov-io

codecov-io commented Aug 23, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #4949 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4949      +/-   ##
==========================================
+ Coverage   81.42%   81.42%   +<.01%     
==========================================
  Files         581      581              
  Lines       90271    90273       +2     
  Branches    10099    10099              
==========================================
+ Hits        73506    73508       +2     
  Misses      14479    14479              
  Partials     2286     2286
Impacted Files Coverage Δ
statsmodels/graphics/tsaplots.py 98.93% <100%> (+0.02%) ⬆️

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 38aa065...47e410f. Read the comment docs.

@bashtage
bashtage force-pushed the default-lags-acf-pacf-plots branch from 14e41f0 to 30f2e86 Compare August 26, 2018 13:58
@bashtage
bashtage force-pushed the default-lags-acf-pacf-plots branch from 30f2e86 to 184d58e Compare September 5, 2018 10:50
@jbrockmendel jbrockmendel mentioned this pull request Sep 8, 2018
31 of 32 tasks
Set a sensible default value for acf and pacf plot lags when not provided
using a method common to R based on the log of the number of observations.
Makes a small aesthetic change that ensures points are inside the shaded confint
Small pep8 clean up

closes statsmodels#4663
closes statsmodels#4748
@bashtage
bashtage force-pushed the default-lags-acf-pacf-plots branch from 184d58e to 47e410f Compare September 9, 2018 15:46
@josef-pkt

Copy link
Copy Markdown
Member

all green, merging

@bashtage Thank you

@josef-pkt
josef-pkt merged commit 1a0d703 into statsmodels:master Sep 10, 2018
@bashtage
bashtage deleted the default-lags-acf-pacf-plots branch September 10, 2018 11:12
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.

ENH: pacf needs to limit nlag to ensure that it is well defined.

4 participants