@TOCVECM
之所以写这篇文章是因为在找寻相关系数解读的资源中,对这方面的介绍比较少,多为专业性的代码分析过程,本人初次使用VECM,根据R语言对系数解读有一定困难,所以当问题解决后记录下过程
本文以短期跨境资本流动的影响因素为例,构建误差修正模型,并最终对模型系数进行解读。
包括ADF检验、滞后阶数的选择、Johansen协整检验、误差修正模型,使用到的R包有:“forecast”,“tseries”,“vars”,“urca”。
文章包括六个变量,分别是被解释变量“跨境资本流动额cf”、解释变量“国内外利差llcy”、“财政赤字czcz”、“汇率变动hhcy”、“GDP增长率gdpz”、“物价水平cpi”
#载入程序包并引入数据
pkgs <- c("forecast","tseries","vars","urca","xlsx")
lapply(pkgs,library,character.only=TRUE)
llcy <- read.xlsx("D:/R/RData/llcy.xlsx",1,encoding = "UTF-8")
cf<- read.xlsx("D:/R/RData/cf.xlsx",1,encoding = "UTF-8")
czcz<- read.xlsx("D:/R/RData/czcz.xlsx",1,encoding = "UTF-8")
hlcy<- read.xlsx("D:/R/RData/hlcy.xlsx",1,encoding = "UTF-8")
gdpz<- read.xlsx("D:/R/RData/gdpz.xlsx",1,encoding = "UTF-8")
cpi<- read.xlsx("D:/R/RData/cpi.xlsx",1,encoding = "UTF-8")
#转化为时间序列数据并汇总
cf <- ts(cf,start=c(1999,12),frequency = 12)
...
cpi <- ts(cpi,start=c(1999,12),frequency = 12)
tdata <- cbind(cf,czcz,hlcy,llcy,gdpz,cpi)
#确定差分阶数并进行差分,差分阶数为1阶
ndifftdata <- ndiffs(tdata)
difftdata <- diff(tdata,differences = 1)
#分别进行ADF检验。P值<0.05,结果稳定。
adf.test(difftdata[,1])
Augmented Dickey-Fuller Test
data: difftdata[, 1]
Dickey-Fuller = -7.5677, Lag order = 6, p-value = 0.01
alternative hypothesis: stationary
Warning message:
In adf.test(difftdata[, 1]) : p-value smaller than printed p-value
...
adf.test(difftdata[,6])
#确定滞后项,根据结果确定K=2
VARselect(difftdata,lag.max = 10,type = "const")
$selection
AIC(n) HQ(n) SC(n) FPE(n)
2 2 2 2
$criteria
1 2 3 4 5
AIC(n) -2.660619e+01 -2.729752e+01 -2.718304e+01 -2.715024e+01 -2.710945e+01
HQ(n) -2.636227e+01 -2.684451e+01 -2.652096e+01 -2.627908e+01 -2.602922e+01
SC(n) -2.600068e+01 -2.617298e+01 -2.553949e+01 -2.498768e+01 -2.442787e+01
FPE(n) 2.786883e-12 1.396718e-12 1.568192e-12 1.624528e-12 1.699036e-12
6 7 8 9 10
AIC(n) -2.701197e+01 -2.697473e+01 -2.696870e+01 -2.698227e+01 -2.698736e+01
HQ(n) -2.572265e+01 -2.547634e+01 -2.526123e+01 -2.506572e+01 -2.486174e+01
SC(n) -2.381137e+01 -2.325512e+01 -2.273007e+01 -2.222463e+01 -2.171070e+01
FPE(n) 1.884296e-12 1.972235e-12 2.006455e-12 2.008154e-12 2.034560e-12
#Johansen协整检验。r=0时检验结果>0,说明变量之间可能存在长期稳定关系。
jo.dtdata <- ca.jo(difftdata,type = c("trace"),ecdet = c("none"),K=2)
summary(jo.dtdata)
######################
# Johansen-Procedure #
######################
Test type: trace statistic , with linear trend
Eigenvalues (lambda):
[1] 0.8024955 0.5720777 0.4174965 0.2920800 0.2593631 0.1823617
Values of teststatistic and critical values of test:
test 10pct 5pct 1pct
r <= 5 | 50.33 6.50 8.18 11.65
r <= 4 | 125.39 15.66 17.95 23.52
r <= 3 | 211.75 28.71 31.52 37.22
r <= 2 | 346.86 45.23 48.28 55.43
r <= 1 | 559.06 66.49 70.60 78.87
r = 0 | 964.56 85.18 90.39 104.20
#建立误差修正模型并得到系数矩阵
cajorls(jo.dtdata,r=1)
$rlm
Call:
lm(formula = substitute(form1), data = data.mat)
Coefficients:
cf.d czcz.d hlcy.d llcy.d gdpz.d
ect1 -3.974e-01 3.151e-01 7.855e-04 -4.237e-02 -2.839e-03
constant -6.614e-04 -1.030e-03 -3.964e-05 -2.398e-04 7.314e-04
cf.dl1 -7.876e-01 1.573e-01 3.301e-03 4.769e-03 -5.331e-04
czcz.dl1 1.277e+00 -1.576e+00 -2.272e-04 3.700e-02 1.140e-02
hlcy.dl1 -7.701e-01 -2.614e-01 -2.556e-01 1.196e-01 3.106e-02
llcy.dl1 1.002e-01 8.916e-02 8.467e-03 -5.061e-01 -7.919e-04
gdpz.dl1 5.090e-01 -2.184e-01 -1.153e-02 -8.293e-01 -2.255e-01
cpi.dl1 5.325e-02 9.001e-03 1.512e-03 1.864e-02 3.608e-04
cpi.d
ect1 -5.631e-02
constant -2.890e-03
cf.dl1 -8.496e-02
czcz.dl1 2.918e-01
hlcy.dl1 3.128e+00
llcy.dl1 1.070e-01
gdpz.dl1 4.543e+00
cpi.dl1 -5.191e-01
$beta
ect1
cf.l2 1.000000000
czcz.l2 -6.543507191
hlcy.l2 -0.453551588
llcy.l2 -0.104339349
gdpz.l2 1.646521015
cpi.l2 -0.003871896
针对误差修正模型的结果解读,当时本文不懂的地方在于如何分析结果,起关键作用的系数是哪些,关键系数从哪里找。
根据系数矩阵,ect1表示误差修正项;constant为常数项;czcz.dl1、hlcy.dl1、llcy.dl1、gdpz.dl1、cpi.dl1分别表示解释变量对被解释变量的影响程度,反应的是长期均衡关系;
$beta系数矩阵为误差修正项的速度调整系数,反应的是序列的短期波动收到均衡回复机制的影响情况,也就是解释变量的短期波动对长期均衡的响应程度。
误差修正项的系数为-0.39,说明当长期均衡关系出现1个单位变化时,短期内总额将会减少0.39个单位。