R-时间序列-分解季节性时间序列

1.季节性时间序列

包含:长期趋势Trend,季节趋势Seasonal,周期循环Circle,随机项Random

这里分解为相加模型X=T+S+C+R

在对时间序列进行分解之前,应该对序列进行检验:(下次写)

2.decompose()函数

将时间序列进行上述分解

3.R分解操作过程

3.1数据读入与可视化

>#以纽约市月出生数量(1946.1-1959.12)的数据集为例

> births <-scan("http://robjhyndman.com/tsdldata/data/nybirths.dat")

Read 168 items

> birthstimeseries <- ts(births, frequency=12, start=c(1946,1))

> plot(birthstimeseries)

出生数量

从图上可以看出,出生数量具有一定的季节性(夏峰冬谷)和周期性,同时趋势性明显;但是每个周期内的波动幅度变化较小,且不随时间趋势而变化,随便波动项随时间变化页不明显。

3.时间序列分解

分解为加法模型

>birthcomponents <- decompose(birthstimeseries)

> plot(birthcomponents)

分解图

4.剔除季节因素

可以对季节性等进行剔除,现剔除季节因素

>birthstimeseriesseasonallyadjusted<-birthstimeseries-birthcomponents$seasonal

>plot(birthstimeseriesseasonallyadjusted)

出生数量(剔除季节因素)

猜你喜欢

转载自blog.csdn.net/It_BeeCoder/article/details/83093430
今日推荐