階差をとって定常になることがわかれば、
gretlで階差をとったデータを用いてモデルの推定をしていたのでできるのかなと思い
とりあえずVARモデルもやってみることにしました。
>>>
●4回の階差をとり、dtmydataへ
> dtmydata<-diff(tmydata,differences=4)
●最適なラグ時数を求める
> VARselect(dtmydata,lag.max=5,type="const")
$selection
AIC(n) HQ(n) SC(n) FPE(n)
5 3 3 3
$criteria
1 2 3 4 5
AIC(n) -7.8877348848 -8.7038693400 -9.0124543099 -8.9609972694 -9.0366540494
HQ(n) -7.8041303583 -8.5645284624 -8.8173770813 -8.7101836899 -8.7301041188
SC(n) -7.5974049145 -8.2199860561 -8.3350177125 -8.0900073585 -7.9721108249
FPE(n) 0.0003760945 0.0001675597 0.0001252448 0.0001362058 0.0001332576
●VARモデルを推定
> dtmydata.var<-VAR(dtmydata,p=5)
> summary(dtmydata.var)
VAR Estimation Results:
=========================
Endogenous variables: inflation, shitsugyo
Deterministic variables: const
Sample size: 26
Log Likelihood: 65.692
Roots of the characteristic polynomial:
0.9592 0.9592 0.8619 0.7874 0.7874 0.7809 0.7809 0.7349 0.7349 0.4464
Call:
VAR(y = dtmydata, p = 5)
Estimation results for equation inflation:
==========================================
inflation = inflation.l1 + shitsugyo.l1 + inflation.l2 + shitsugyo.l2 + inflation.l3 + shitsugyo.l3 + inflation.l4 + shitsugyo.l4 + inflation.l5 + shitsugyo.l5 + const
Estimate Std. Error t value Pr(>|t|)
inflation.l1 -1.927315 0.339514 -5.677 4.39e-05 ***
shitsugyo.l1 -0.009345 0.013917 -0.671 0.51214
inflation.l2 -1.923576 0.563393 -3.414 0.00384 **
shitsugyo.l2 -0.006812 0.022253 -0.306 0.76373
inflation.l3 -1.448192 0.529341 -2.736 0.01532 *
shitsugyo.l3 -0.001956 0.027544 -0.071 0.94432
inflation.l4 -0.948615 0.428317 -2.215 0.04268 *
shitsugyo.l4 -0.008059 0.023203 -0.347 0.73316
inflation.l5 -0.319913 0.209567 -1.527 0.14768
shitsugyo.l5 0.003144 0.014380 0.219 0.82989
const 0.000278 0.004420 0.063 0.95068
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.0222 on 15 degrees of freedom
Multiple R-Squared: 0.8736, Adjusted R-squared: 0.7893
F-statistic: 10.37 on 10 and 15 DF, p-value: 4.649e-05
Estimation results for equation shitsugyo:
==========================================
shitsugyo = inflation.l1 + shitsugyo.l1 + inflation.l2 + shitsugyo.l2 + inflation.l3 + shitsugyo.l3 + inflation.l4 + shitsugyo.l4 + inflation.l5 + shitsugyo.l5 + const
Estimate Std. Error t value Pr(>|t|)
inflation.l1 15.63073 8.67003 1.803 0.0915 .
shitsugyo.l1 -1.01870 0.35541 -2.866 0.0118 *
inflation.l2 22.18800 14.38712 1.542 0.1439
shitsugyo.l2 -0.99285 0.56826 -1.747 0.1010
inflation.l3 15.98320 13.51754 1.182 0.2554
shitsugyo.l3 -0.46093 0.70339 -0.655 0.5222
inflation.l4 8.44936 10.93775 0.772 0.4518
shitsugyo.l4 0.14120 0.59252 0.238 0.8149
inflation.l5 3.31836 5.35161 0.620 0.5445
shitsugyo.l5 0.19340 0.36721 0.527 0.6061
const -0.04179 0.11288 -0.370 0.7164
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.5669 on 15 degrees of freedom
Multiple R-Squared: 0.8218, Adjusted R-squared: 0.703
F-statistic: 6.918 on 10 and 15 DF, p-value: 0.0004948
Covariance matrix of residuals:
inflation shitsugyo
inflation 0.0004929 -0.009624
shitsugyo -0.0096239 0.321417
Correlation matrix of residuals:
inflation shitsugyo
inflation 1.0000 -0.7646
shitsugyo -0.7646 1.0000
●インパルス応答関数
> dtmydata.irf<-irf(dtmydata.var,n.ahead=14,ci=0.95)
> plot(dtmydata.irf)
Hit
to see next plot: ●グレンジャー因果性検定 > causality(dtmydata.var,cause="inflation") $Granger Granger causality H0: inflation do not Granger-cause shitsugyo data: VAR object dtmydata.var F-Test = 0.6887, df1 = 5, df2 = 30, p-value = 0.6358 $Instant H0: No instantaneous causality between: inflation and shitsugyo data: VAR object dtmydata.var Chi-squared = 9.5925, df = 1, p-value = 0.001954 ●一期先を予測 > dtmydata.pr<-predict(dtmydata.var,n.ahead=1,ci=0.95,dumvar=NULL) > dtmydata.pr $inflation fcst lower upper CI inflation.fcst -0.003584949 -0.04709803 0.03992813 0.04351308 $shitsugyo fcst lower upper CI shitsugyo.fcst -1.762654 -2.873828 -0.651479 1.111175 > > plot(dtmydata.pr) <<< インパルス応答関数とグレンジャー因果性検定はこのままでもいいのかもしれないけど 階差データを使っているので予測値はどうなるんだろう? VARモデルに投入した配列に予測値の行を追加してdiffinvかなぁと予想するものの いろいろ調べても方法がわからなくて困っている最中です。 というところで、一旦切りたいと思います。