I'm trying to compare my original time series with my multiplicative seasonally adjusted, after that I will check additive to see which one is more smoother.
autoplot(data_tsbl) +
autolayer(data_tsbl_a$season_adjust, color = "red") +
labs(title = "Comparing original X multiplicative seasonal adjusted",
x = "Time",
y = "Number of Passengers")
theme_minimal()
ibrary(forecast)
#> Error in ibrary(forecast): could not find function "ibrary"
library(tsibble)
#>
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, union
library(feasts)
#> Loading required package: fabletools
library(tidyverse)
data_tsbl <- as_tsibble(ts(AirPassengers,
start = c(1949, 1),
frequency = 12))
data_tsbl_a <- data_tsbl %>%
model(STL(box_cox(value, lambda = 1))) %>%
components()
data_tsbl["adjusted"] <- data_tsbl_a$season_adjust
data_tsbl %>% autoplot(vars(value,adjusted)) + theme_minimal()
data_tsbl %>% autoplot(value) +
autolayer(vars(adjusted)) + theme_minimal()
#> Error: Objects of type quosures/list not supported by autolayer.
p <- ggplot(data_tsbl,aes(index))
p + geom_line(aes(,value, color = "Original")) +
geom_line(aes(,adjusted, color = "Adjusted")) +
labs(title = "Comparing original X multiplicative seasonal adjusted",
x = "Time", y = "Number of Passengers") +
theme_minimal()
Thanks for your prompt reply, do you think there is a way to forecast a multiplicative seasonal adjust time series? in my research I just saw an automated way :
Thanks for sharing a suitable solution, since the multiplicative is the smoother one I'm trying to fit with ses model according to the code below, and I got some issue:
simple <- data_tsbl %>%
model(dcmcp_spec_ad) %>%
forecast(h = "1 year")
My warning message: Warning message:
1 error encountered for dcmcp_spec_ad
[1] Suitable defaults for these decomposition elements are not available: trend, remainder.
Please specify an appropriate model for these components
A small point, but why do you still transform a ts to a ts before transforming to a tsibble? Also, loading the fpp3 package will also load the other packages you need. It is much easier than loading each one individually.
I am grading finals right now so will not be checking in very often. Good luck!
An example in section 13.4 of fpp3 uses a log transformation to fit a multiplicative STL model, which yields the seasonal effects (for the forecast using SNAIVE) and the seasonally adjusted values, which it passes to an ETS model (without seasonality) but no explicit back-transformation, so it must handle that automatically.
Thanks for helping me with this topic, I could handle this issue, after your help.
Something that I what studying now is Machine learning methods for forecasts in tidyverse, you know some book that I could find relevant information about it?