上篇说明了分解非季节性数据的方法。就是通过TTS包的SMA()函数进行简单移动平均平滑。让看似没有规律或没有趋势的曲线变的有规律或趋势。然后再进行时间序列曲线的回归预测。
> births <- scan("http://robjhyndman.com/tsdldata/data/nybirths.dat")
Read 168 items
> birthstimeseries <- ts(births, frequency=12, start=c(1946,1))
> ts.plot(birthstimeseries)
> birthcomponents <-
decompose(birthstimeseries)
> plot(birthcomponents)

而当你需要剔除某个趋势时(我们就去掉季节因素),我们可以运用减法去掉该因素,下图就是去掉季节性因素后的修正序列。
>
birthstimeseriesseasonallyadjusted<-birthstimeseries-birthcomponents$seasonal
>
plot(birthstimeseriesseasonallyadjusted)

留下记录,供日后复习应用。