2016-03-01 1038 views
2

一旦我完成了STL或时间序列数据的分解,我该如何提取每个组件的模型? 例如,如何获得趋势的斜率和截距,季节数据的周期等? 如果需要,我可以提供样本数据,但这是一个通用的问题。从STL获取趋势和季节模型/分解

+0

这是一个黄土分解。 – 2016-03-01 07:40:47

回答

4

作为对您的问题的部分回答,如果趋势线性化,则可以很容易地提取趋势。下面是一个例子:

library(forecast) 
plot(decompose(AirPassengers)) 

enter image description here

在线性趋势的情况下,我们可以使用tslm()函数提取的截距和斜率

tslm(AirPassengers ~ trend) 

Call: 
lm(formula = formula, data = "AirPassengers", na.action = na.exclude) 

Coefficients: 
(Intercept)  trend 
    87.653  2.657 

为了获得包括季节的拟合,这可以像

fit <- tslm(AirPassengers ~ trend + season) 
> summary(fit) 

Call: 
lm(formula = formula, data = "AirPassengers", na.action = na.exclude) 

Residuals: 
    Min  1Q Median  3Q  Max 
-42.121 -18.564 -3.268 15.189 95.085 

Coefficients: 
      Estimate Std. Error t value Pr(>|t|)  
(Intercept) 63.50794 8.38856 7.571 5.88e-12 *** 
trend   2.66033 0.05297 50.225 < 2e-16 *** 
season2  -9.41033 10.74941 -0.875 0.382944  
season3  23.09601 10.74980 2.149 0.033513 * 
season4  17.35235 10.75046 1.614 0.108911  
season5  19.44202 10.75137 1.808 0.072849 . 
season6  56.61502 10.75254 5.265 5.58e-07 *** 
season7  93.62136 10.75398 8.706 1.17e-14 *** 
season8  90.71103 10.75567 8.434 5.32e-14 *** 
season9  39.38403 10.75763 3.661 0.000363 *** 
season10  0.89037 10.75985 0.083 0.934177  
season11 -35.51996 10.76232 -3.300 0.001244 ** 
season12  -9.18029 10.76506 -0.853 0.395335  
--- 
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 26.33 on 131 degrees of freedom 
Multiple R-squared: 0.9559, Adjusted R-squared: 0.9518 
F-statistic: 236.5 on 12 and 131 DF, p-value: < 2.2e-16 

如果我正确解释这个结果,每月平均增加2.66乘客,并且第二个月平均有9.4个乘客比第一个月少等。

+0

但趋势不是线性的,对吗? – 2016-03-01 07:50:29

+0

这很大程度上取决于时间序列。有时需要首先执行日志转换。在这种特殊情况下,它是“合理”的线性)。线性的系统偏差显示在底部的“随机”组件上。 – RHertel

+0

我的意思是,在你的例子中。趋势不是线性的。 – 2016-03-01 07:53:15