トレンド抽出 指数関数によるトレンド

Equation y_{t}=Ae^{rt} \ln{y_{t}}=\ln{A}+rtR サンプルデータ:1947年から2013年までのアメリカの実質GDP gpdusaloggpdusa fitloggpdusafitgpdusa gpdusa02residgpdusa
> library(tseries)

> gdp <- ts(dataset$gdp,start=c(1947,1),frequency=4)

> plot(gdp,main="Real GDP.USA.1947/1-2013/10",ylab="bln$")

> adf.test(gdp)

        Augmented Dickey-Fuller Test

data:  gdp
Dickey-Fuller = -1.5033, Lag order = 6, p-value = 0.7852
alternative hypothesis: stationary

> adf.test(diff(gdp))

        Augmented Dickey-Fuller Test

data:  diff(gdp)
Dickey-Fuller = -5.418, Lag order = 6, p-value = 0.01
alternative hypothesis: stationary

 警告メッセージ: 
In adf.test(diff(gdp)) : p-value smaller than printed p-value

> lgdp <- log(gdp)

> plot(lgdp,main="Log.Real GDP.USA.1947/1-2013/10",ylab="-")

> time <- seq(1,length(lgdp))

> kaiki <- lm(lgdp~time)

> summary(kaiki)

Call:
lm(formula = lgdp ~ time)

Residuals:
      Min        1Q    Median        3Q       Max 
-0.145620 -0.027788  0.009955  0.039594  0.096315 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) 7.642e+00  6.954e-03  1098.9   <2e-16 ***
time        8.133e-03  4.482e-05   181.5   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05677 on 266 degrees of freedom
Multiple R-squared:  0.992,     Adjusted R-squared:  0.992 
F-statistic: 3.293e+04 on 1 and 266 DF,  p-value: < 2.2e-16

> lgdptrend <- ts(kaiki$fitted,start=c(1947,1),frequency=4)

> plot(lgdp,main="Log.Real GDP.USA.1947/1-2013/10",ylab="-",ylim=c(7.5,10))
> par(new=T)
> plot(lgdptrend,main="",ylab="",ylim=c(7.5,10),type="l",col=2)

> gdptrend <- ts(exp(kaiki$fitted),start=c(1947,1),frequency=4)

> gdptrend.resi <- ts(exp(kaiki$resid),start=c(1947,1),frequency=4)

> plot(gdp,main="Real GDP.USA.1947/1-2013/10",ylab="bln$",ylim=c(1500,17000))
> par(new=T)
> plot(gdptrend,main="",ylab="",ylim=c(1500,17000),xlab="",col=2)

> plot(gdptrend.resi,main="Residuals.Real GDP.USA.1947/1-2013/10",ylab="-")

> plot(gdptrend*gdptrend.resi,main="Real GDP.Trend*Residual.USA.1947/1-2013/10",ylab="10bln",ylim=c(1500,17000))
> 

参考文献 田中孝文(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/.