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

STL decomposition: odd behavior when season(period = 1) #146

Closed
pgg1309 opened this issue Feb 3, 2022 · 7 comments
Closed

STL decomposition: odd behavior when season(period = 1) #146

pgg1309 opened this issue Feb 3, 2022 · 7 comments

Comments

@pgg1309
Copy link

pgg1309 commented Feb 3, 2022

Hello,

I was trying to change the degree of smoothness of the trend in an STL decomposition with no seasonal period.

Below the codes:
dcmp <- aus_production %>% model(STL(Beer ~ trend(window = 3) + season(period = 1)))
components(dcmp) %>% autoplot()

If I change to trend(window = 33) or any other number, there is no change in the output.

Is this the expected behavior ? Shouldn't this result in different trend smoothness ?

@robjhyndman
Copy link
Member

season(period = 1) should give an error because you can't have seasonality with period 1. For some reason, rather than giving an error, it seems to be ignoring the argument for trend()

@pgg1309
Copy link
Author

pgg1309 commented Feb 3, 2022

season(period = 1) should give an error because you can't have seasonality with period 1. For some reason, rather than giving an error, it seems to be ignoring the argument for trend()

But isn't this an option used in your book to detect outliers?

I got the idea to use season(period = 1) from
https://otexts.com/fpp3/missing-outliers.html
but I was trying to be a bit more flexible on the 'trend'.

@robjhyndman
Copy link
Member

Hmm. Yes, I'd forgotten that -- we do need a way to fit a non-seasonal STL when there would otherwise be a seasonal component. Setting period=1 was my hack to force that to occur. Maybe would be more transparent to have some other specification.

In any case, the trend() argument is being ignored in this situation. So that needs fixing.

@mitchelloharawild
Copy link
Member

This is because stats::stl() only works for seasonal series, and we fall back to stats::supsmu() for non-seasonal cases. Removing this (bad) functionality would be too much of a breaking change, as many users use STL in non-seasonal applications. Adding a warning wouldn't be a bad idea.

The long term solution is to re-implement STL to not use stats::supsmu(), and instead allow for more flexible specification of the stl model. This change is described in #62 but will take a bunch of work.

@pgg1309
Copy link
Author

pgg1309 commented Feb 3, 2022

I saw the fall back to stats::supsmu() and tried to use the parameter bass to adjust the smoothness of the trend. But it also did not work. I am not sure, though, whether I did it the right way. I assumed there would be a ... parameter at the end of the STL() call and therefore tried to add STL(Beer ~ season(period = 1), bass = 5) but it failed to work.

@mitchelloharawild
Copy link
Member

... isn't passed through to stats::supsmu(), it is passed to stats::stl() instead.

@mitchelloharawild
Copy link
Member

Closing as the misunderstanding seems resolved, and is now a duplicate of #62

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

3 participants