我想了解R中STL函数的预测是如何工作的。所以,我在这里没有提供任何可重现的代码。
以下是我处理时间序列的程序
现在,我的任务是计算包含的预测值 一个。上面第1步中的季节性和趋势分量 湾来自ARIMA模型的残差成分 - 来自上面的第3步。
如果我使用
forecast(stl(..)),
它给了我
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
但是,我只关注预测的季节性和趋势部分。如何获得季节性趋势组件?
构成预测的组件(stl(..))
请告知。
答案 0 :(得分:0)
我不确定您是否要使用STL预测,但如果您只想从STL中提取季节性和趋势分量,那么下面的代码可能对您有用。
## Let's build a monthly time series first
dat_monthly <- cumsum(rnorm(39,0,5))
x_monthly <- ts(dat_monthly, frequency = 12, start = c(2013,1))
stl(x_monthly, "periodic")
stl(x_monthly, s.window = "periodic")$time.series[, "seasonal"] ## for seasonal part
stl(x_monthly, s.window = "periodic")$time.series[, "trend"] ## for trend part