Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Retrieve STL used window values #154

Open
david-vicente opened this issue Oct 20, 2022 · 2 comments
Open

[Question] Retrieve STL used window values #154

david-vicente opened this issue Oct 20, 2022 · 2 comments

Comments

@david-vicente
Copy link

For STL, is there a way to retrieve the used window parameter values after fitting the model?

If we use the str function,

my_tsibble %>% model(STL(column ~ trend())) %>% str()

we can find all the "learned" periods

.. .. .. ..$ season_week:List of 2
.. .. .. .. ..$ period: num 168
.. .. .. .. ..$ base  : num 0
.. .. .. ..$ season_day :List of 2
.. .. .. .. ..$ period: num 24
.. .. .. .. ..$ base  : num 0

but I can't find the other parameters such as the window size.

@mitchelloharawild
Copy link
Member

It's stored in the model object, but this isn't intended for users. If needed I can expose it in the user accessible methods for the model. Are you trying to obtain the defaults for these windows?

@david-vicente
Copy link
Author

david-vicente commented Oct 20, 2022

Are you trying to obtain the defaults for these windows?

Yeah. Since in the example above I haven't defined a window for trend(), which according to the documentation depends on the period and window size of the seasons, I'm not really sure what was the chosen window.

The documentation says

nextodd(ceiling((1.5*period) / (1-(1.5/s.window))))

but because this is an implementation of MSTL we have more than one season, each with its respective window and period. I would like to be able to retrieve the defaults picked in this case.

Another situation is when we set the window for trend (and the model extracts 2 seasonal components):

my_tsibble %>% model(STL(column ~ trend(window=11)))

here I'm assuming that the windows used are

trend_window = 11
season1_window = 11
season2_window = 15

since the documentation states

The default (NULL) will choose an appropriate default, for a dataset with one seasonal pattern this would be 11, the second larger seasonal window would be 15, then 19, 23, ... onwards.

Am I correct?

Nonetheless, I think that exposing this to the user would be beneficial, so that for example one could train a decomposition model in R, retrieve the values, and use them in another implementation for comparison, lets say in Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants