ENH Added Seasonal-Diagnostic Plot to graphics.tsaplots#9519
ENH Added Seasonal-Diagnostic Plot to graphics.tsaplots#9519jalopezp wants to merge 7 commits intostatsmodels:mainfrom
Conversation
determine the `seasonal` parameter in `STL`.
Made long line shorter
bashtage
left a comment
There was a problem hiding this comment.
Some changes to improve the performance and interpretation. Also need to add a test that will run through the various configurations of optional arguments to make sure there aren't any issues. Test is only really for smoke as we dont' verify the figure.
statsmodels/graphics/tsaplots.py
Outdated
| period_length : int | ||
| The length of the period. Should match the `period` parameter used to | ||
| decompose the series. | ||
| select : int |
There was a problem hiding this comment.
I don't really get much from select, or its description. Is this the base name?
There was a problem hiding this comment.
I was testing this with the co2 dataset where the periodicity is 52. 52 subplots is too many so I added this parameter to specify how many to subcycles to select and plot. A disadvantage here was that the subplots were selected for you, so you couldn't ask it to display the first 13 weeks, then the next 13 weeks and so on. But I've added the option to select which subcycles specifically to plot by passing in a list. Called the parameter subplots, hope it's better.
| Returns an matplotlib object of type Figure with the | ||
| Seasonal-Diagnostic Plot. | ||
|
|
||
|
|
There was a problem hiding this comment.
Perhaps add an
Example
-------
section. Ideally one that will generate an actual plot which can then appear in the web docs.
statsmodels/graphics/tsaplots.py
Outdated
| fig, axs = mpl.pyplot.subplots(sharex=True, sharey=True, | ||
| squeeze=False, nrows=nrows, **kwargs) | ||
|
|
||
| p_to_plot = [math.floor(i*period_length / select) for i in range(select)] |
There was a problem hiding this comment.
Please use np.floor and vector ops. We almost exclusively avoid math.
Something like
np.floor(np.arange(select) * period_length / select))
statsmodels/graphics/tsaplots.py
Outdated
|
|
||
| p_to_plot = [math.floor(i*period_length / select) for i in range(select)] | ||
| if subseries_labels is None: | ||
| subseries_labels = [f'Cycle-subseries {i + 1}' for i in period_length] |
There was a problem hiding this comment.
If not none you should check that there are enough and error if not.
statsmodels/graphics/tsaplots.py
Outdated
|
|
||
| for ax, k in zip(fig.get_axes(), p_to_plot): | ||
| ax = seasonplot(x, k, period_length, ax=ax) | ||
| ax.set_title(subseries_labels[k]) |
There was a problem hiding this comment.
Best to throw a str(...) around the labels in case of user ones
…sonaldiagnosticplot # Conflicts: # statsmodels/graphics/tsaplots.py
|
Would be nice to get this in. Could you clean the notebook? We only store unrendered notebooks. |
|
Closed and reopen to get new CI |
STL requires a parameter called
seasonalto be set. The authors of the technique recommend a plot called the Seasonal-Diagnostic Plot to visualise how theseasonalparameter is affecting the seasonal components. I added this plot tographics.tsaplotsand a notebook to explain how to use it.