トレンド抽出

Equation
加法モデル
Y_{t}=T_{t}+C_{t}+S_{t}+I_{t}

乗法モデル
Y_{t}=T_{t}\times C_{t}\times S_{t}\times I_{t}
\log{Y_{t}}=\log{T_{t}}+\log{C_{t}}+\log{S_{t}}+\log{I_{t}}

T:傾向変動(trend)、C:循環変動(cycle)、S:季節変動(seasonal)、I:不規則変動(irregular).

R
サンプルデータ:1994年2月から2014年2月までのアメリカの失業率(季節調整なし)
unrateusaunrateusadecomunrateusaacf

> library(tseries)
> unemp <- ts(dataset$unrateusa,start=c(1994,2),frequency=12)
> plot(unemp,main="Unemployment Rate of U.S.A.1994/2-2014/2.NSA",ylab="Rate(%)")

> adf.test(unemp)

        Augmented Dickey-Fuller Test

data:  unemp
Dickey-Fuller = -1.8018, Lag order = 6, p-value = 0.6592
alternative hypothesis: stationary

> adf.test(diff(unemp))

        Augmented Dickey-Fuller Test

data:  diff(unemp)
Dickey-Fuller = -3.9907, Lag order = 6, p-value = 0.01015
alternative hypothesis: stationary

> trend.unemp <- decompose(unemp)

> plot(trend.unemp)

> str(trend.unemp)
List of 6
 $ x       : Time-Series [1:241] from 1994 to 2014: 7.1 6.8 6.2 5.9 6.2 6.2 5.9 5.6 5.4 5.3 ...
 $ seasonal: Time-Series [1:241] from 1994 to 2014: 0.414 0.218 -0.257 -0.237 0.21 ...
 $ trend   : Time-Series [1:241] from 1994 to 2014: NA NA NA NA NA ...
 $ random  : Time-Series [1:241] from 1994 to 2014: NA NA NA NA NA ...
 $ figure  : num [1:12] 0.414 0.218 -0.257 -0.237 0.21 ...
 $ type    : chr "additive"
 - attr(*, "class")= chr "decomposed.ts"

> acf(unemp,lag=36)

参考文献
田中孝文(2008).『Rによる時系列分析入門』.シーエーピー出版.393pp.

アプリケーション
R Core Team (2013). R: A language and environment for statistical computing.
R Foundation for Statistical Computing, Vienna, Austria.
URL http://www.R-project.org/.