如何在R中运行纠错模型?

时间:2014-10-17 11:02:35

标签: r statistics time-series causality

使用过的函数,包和数据:

  1. 我使用了2个时间序列,有51次观察

    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)
    
  2. 我使用了函数ecmAsyFit(),来自包&#34; apt&#34;:

    ecmAsyFit(gdp, life, lag = 1, split = TRUE,model = "linear", thresh = 0)

  3. 问题:

    1. 运行该功能后,得到以下结果:

      Error in ecmAsyFit(gdp, life, lag = 1, split = TRUE, model = "linear", : Please provide time series data.

    2. 问题:

      1. 如何以适当的方式运行此功能?

1 个答案:

答案 0 :(得分:2)

也许这就是你所追求的:

library(apt)

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)

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)

此外......你可以通过查看合适的结构找到所有结果......

str(fit)