I have an issue when trying to use stl + random walk in R to forecast. I have weekly temperature data between the 7th week of 2016 and 2019 in data and use the following code:
ts <- as.ts(data$Temp , start = c(2016,7),end = c(2019,12), frequency= 52)
plot(ts)
stl_rw <- stlf(ts, forecastfunction = rwf)
When eyeballing the plot(ts)
, I can see some periodicity, yet I continue to get the error:
y is not a seasonal ts object.
. I've also tried to convert the weekly data to monthly data, but had the same error. Thank you in advance for the help!
try to use ts
instead of as.ts
:
myts <- ts(data$Temp , start = c(2016,7), frequency = 52)
plot(myts)
stl_rw <- stlf(myts, forecastfunction = rwf)