Closed robjhyndman closed 5 years ago
By default tsfeatures()
will scale the time series, which features()
does not do.
library(tsfeatures)
library(feasts)
#> Loading required package: fabletools
#>
#> Attaching package: 'feasts'
#> The following objects are masked from 'package:tsfeatures':
#>
#> unitroot_kpss, unitroot_pp
set.seed(20190910)
x <- ts(rnorm(100), frequency = 24)
tsfeatures(x,"stl_features", s.window='periodic', robust=TRUE, scale = FALSE)
#> # A tibble: 1 x 11
#> nperiods seasonal_period trend spike linearity curvature e_acf1
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 24 0.0135 4.25e-4 0.0328 -1.23 -0.0425
#> # … with 4 more variables: e_acf10 <dbl>, seasonal_strength <dbl>,
#> # peak <dbl>, trough <dbl>
as_tsibble(x) %>%
features(value, list(~ feat_stl(., .period=24, s.window='periodic', robust=TRUE)))
#> # A tibble: 1 x 7
#> trend_strength seasonal_streng… spikiness linearity curvature
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.0135 0.161 0.000425 0.0328 -1.23
#> # … with 2 more variables: seasonal_peak_24 <dbl>,
#> # seasonal_trough_24 <dbl>
Created on 2019-09-10 by the reprex package (v0.3.0)
As for lumpiness()
and var_tiled_var()
, the latter is including the partial tile window at the end of the series. So if a series is length 100 and the window size is 24, it will be using 5 windows (one with size 4) unlike lumpiness()
which ignores the end of the series. Probably best to ignore partial windows here?
As for max_*_shift()
and shift_*_max()
only the index
/time
varies after setting scale = FALSE
. This is because tsfeatures
reports time
as the window number that maximises the shift.
Effectively I think tsfeatures
is outputting the index of the window's left, whereas feasts
reports the index of the right-most element of the window. If a right-aligned sliding window is most appropriate here, I think the output in feasts
is most appropriate.
feat_stl
?Actually if we add a scale argument anywhere, it should probably be to features()
. Would you rather that, or make the user create the scaled data directly like this?
df <- df %>%
group_by(key) %>%
mutate(z = scale(value)) %>%
ungroup()
I'd prefer scale to be user controllable, perhaps even:
df %>%
features(scale(value), ...)
features(scale(value), ..)
would be great.
Now possible with fabletools.
I think these should all give the same results.
Created on 2019-09-10 by the reprex package (v0.3.0)