-
Notifications
You must be signed in to change notification settings - Fork 31
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
How to change period in features(var, feat_stl)
#371
Comments
Thanks for raising this, I think this should be made to work better. Essentially the Instead you could wrap it in a list, which is the recommended approach for providing one or more features. tourism |>
features(Trips, list(~feat_stl(., .period = "1 year"))) However this runs into a secondary issue in that So ultimately, what works is: tourism |>
features(Trips, list(~feat_stl(., .period = 4))) 9a1e6fd now supports lambda functions being used directly. f8a8baa allows you to use So I would recommend (with these latest changes) for your example: library(fpp3)
tourism |>
features(Trips, feat_stl, .period = "1 year")
#> # A tibble: 304 × 12
#> Region State Purpose trend…¹ seaso…² seaso…³ seaso…⁴ spiki…⁵ linea…⁶ curva…⁷
#> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Adelai… Sout… Busine… 0.464 0.407 3 1 1.58e+2 -5.31 71.6
#> 2 Adelai… Sout… Holiday 0.554 0.619 1 2 9.17e+0 49.0 78.7
#> 3 Adelai… Sout… Other 0.746 0.202 2 1 2.10e+0 95.1 43.4
#> 4 Adelai… Sout… Visiti… 0.435 0.452 1 3 5.61e+1 34.6 71.4
#> 5 Adelai… Sout… Busine… 0.464 0.179 3 0 1.03e-1 0.968 -3.22
#> 6 Adelai… Sout… Holiday 0.528 0.296 2 1 1.77e-1 10.5 24.0
#> 7 Adelai… Sout… Other 0.593 0.404 2 2 4.44e-4 4.28 3.19
#> 8 Adelai… Sout… Visiti… 0.488 0.254 0 3 6.50e+0 34.2 -0.529
#> 9 Alice … Nort… Busine… 0.534 0.251 0 1 1.69e-1 23.8 19.5
#> 10 Alice … Nort… Holiday 0.381 0.832 3 1 7.39e-1 -19.6 10.5
#> # … with 294 more rows, 2 more variables: stl_e_acf1 <dbl>, stl_e_acf10 <dbl>,
#> # and abbreviated variable names ¹trend_strength, ²seasonal_strength_4,
#> # ³seasonal_peak_4, ⁴seasonal_trough_4, ⁵spikiness, ⁶linearity, ⁷curvature or library(fpp3)
tourism |>
features(Trips, ~feat_stl(., .period = 4))
#> # A tibble: 304 × 12
#> Region State Purpose trend…¹ seaso…² seaso…³ seaso…⁴ spiki…⁵ linea…⁶ curva…⁷
#> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 Adelai… Sout… Busine… 0.464 0.407 3 1 1.58e+2 -5.31 71.6
#> 2 Adelai… Sout… Holiday 0.554 0.619 1 2 9.17e+0 49.0 78.7
#> 3 Adelai… Sout… Other 0.746 0.202 2 1 2.10e+0 95.1 43.4
#> 4 Adelai… Sout… Visiti… 0.435 0.452 1 3 5.61e+1 34.6 71.4
#> 5 Adelai… Sout… Busine… 0.464 0.179 3 0 1.03e-1 0.968 -3.22
#> 6 Adelai… Sout… Holiday 0.528 0.296 2 1 1.77e-1 10.5 24.0
#> 7 Adelai… Sout… Other 0.593 0.404 2 2 4.44e-4 4.28 3.19
#> 8 Adelai… Sout… Visiti… 0.488 0.254 0 3 6.50e+0 34.2 -0.529
#> 9 Alice … Nort… Busine… 0.534 0.251 0 1 1.69e-1 23.8 19.5
#> 10 Alice … Nort… Holiday 0.381 0.832 3 1 7.39e-1 -19.6 10.5
#> # … with 294 more rows, 2 more variables: stl_e_acf1 <dbl>, stl_e_acf10 <dbl>,
#> # and abbreviated variable names ¹trend_strength, ²seasonal_strength_4,
#> # ³seasonal_peak_4, ⁴seasonal_trough_4, ⁵spikiness, ⁶linearity, ⁷curvature Created on 2022-10-27 by the reprex package (v2.0.1) |
Thanks for the quick updates. Having examples like these in the documentation for maybe |
I can't seem to figure out how to add arguments to
feat_stl
when it is used inside offeatures()
. I would expect an anonymous function to work, but it doesn't.Reprex:
Created on 2022-10-25 with reprex v2.0.2
Session info
The text was updated successfully, but these errors were encountered: