在R中复制纠错模型(ECM)的例子?

时间:2014-10-31 14:09:42

标签: r statistics time-series causality

我使用过EViews并运行错误修正模型(ECM)并获得了一些结果。现在我想在R中复制该示例并获得与我在EViews中所做的相同的结果。

我使用的数据如下:

    gdp<-c(6592.694,7311.75,7756.11,8374.175,9169.984,9994.071,10887.682,11579.432,12440.625,13582.799,15261.26,17728.673,21899.262,29300.921,34933.51,39768.017,42647.701,51144.915,61554.743,73407.498,81467.464,70500.215,70682.449,71496.768,67403.443,68781.085,98203.625,123083.47,131969.428,131738.237,164753.092,172008.565,193073.835,188423.703,201444.061,238561.784,234676.457,207826.099,213329.585,212301.777,192070.75,191678.678,207537.337,253945.777,291430.382,304983.602,324954.402,375041.784,414173.646,381775.165,376575.382)
    life<-c(68.58560976,69.57731707,69.3095122,69.44365854,69.92195122,69.72219512,70.04585366,69.91780488,70.05756098,69.83317073,69.89073171,70.06926829,70.41365854,70.97926829,70.96243902,71.08414634,71.55121951,71.89536585,71.96707317,72.28731707,72.42365854,72.75804878,72.89707317,72.96853659,73.52756098,73.74512195,74.22292683,74.66926829,75.14414634,75.24804878,75.53,75.56780488,75.85536585,76.10634146,76.45707317,76.71560976,76.98365854,77.38756098,77.57317073,77.77560976,78.02682927,78.52682927,78.67804878,78.63170732,79.1804878,79.33170732,79.83170732,79.98292683,80.23414634,80.08292683,80.38292683)

我在EViews中获得并希望在R中复制的结果如下表所示: enter image description here

我使用了包 apt及其功能 ecmAsyFit(gdp, life, lag = 1, split = TRUE,model = "linear", thresh = 0) 我运行的代码如下:

df <- ts(cbind(gdp, life), start = 1950, freq = 1)
fit <-   ecmAsyFit(df[, 1], df[, 2], lag = 1, split = TRUE, model = "linear", thresh = 0)
summary(fit)

获得的R 中的结果显示在:

              DepVar                 IndVar     estimate     error t.value p.value signif
1  diff.df[, 2].t_0  |            (Intercept)      0.324     0.063   5.135   0.000    ***
2                    | X.diff.df[, 2].t_1.pos     -0.458     0.155  -2.954   0.005    ***
3                    | X.diff.df[, 2].t_1.neg      0.443     0.546   0.811   0.422       
4                    | X.diff.df[, 1].t_1.pos      0.000     0.000   1.410   0.166       
5                    | X.diff.df[, 1].t_1.neg      0.000     0.000  -1.475   0.148      .
6                    |          X.ECT.t_1.pos      0.000     0.000  -1.819   0.076      *
7                    |          X.ECT.t_1.neg      0.000     0.000  -0.420   0.677       
8  diff.df[, 1].t_0  -            (Intercept)   3793.752  4912.683   0.772   0.444       
9                    - X.diff.df[, 2].t_1.pos  -4510.643 12060.505  -0.374   0.710       
10                   - X.diff.df[, 2].t_1.neg -21884.942 42483.319  -0.515   0.609       
11                   - X.diff.df[, 1].t_1.pos      0.576     0.190   3.031   0.004    ***
12                   - X.diff.df[, 1].t_1.neg      0.055     0.369   0.148   0.883       
13                   -          X.ECT.t_1.pos     -0.318     0.145  -2.193   0.034     **
14                   -          X.ECT.t_1.neg     -0.175     0.130  -1.354   0.183       

问题: 我在EViews(显示的表)中获得的结果与R(在右上方显示)

不同

问题:

  1. 有没有办法使用ecmAsyFit函数获取结果,如表中所示?
  2. 是否有其他功能(或一组功能)可以运行错误修正模型并提供表格中显示的结果?
  3. 有人可以共享应用错误更正模型的代码,所以我可以申请吗?

1 个答案:

答案 0 :(得分:1)

我认为应该如下:

 df <- ts(cbind(gdp, life), start = 1950, freq = 1)

#对称VECM

 fit1<- ecmSymFit(df[, 1], df[, 2], lag = 1)

#Setting split = FALSE使协整集成对称。

fit2<- ecmAsyFit(df[, 1], df[, 2], lag = 1, split =FALSE, model = "linear", thresh = 0)
summary(fit)