Granger Causality

取阈值:首先进行回归分析,然后得到的参数,进行排序,根据极端冲击,负极端取0.1,正极端取0.9,作为相应变量的阈值

10个类别(9个是积极,正常,消极的组合,剩下一个是传统格兰特方法)

{shockprc:分类}

[egin{array}{l} left(X_{t}^{+}, Y_{t}^{+} ight),left(X_{t}^{+}, Y_{t}^{*} ight),left(X_{t}^{+}, Y_{t}^{-} ight) \ left(X_{t}^{*}, Y_{t}^{*} ight),left(X_{t}^{*}, Y_{t}^{-} ight),left(X_{t}^{*}, Y_{t}^{+} ight) \ left(X_{t}^{-}, Y_{t}^{*} ight),left(X_{t}^{-}, Y_{t}^{+} ight),left(X_{t}^{-}, Y_{t}^{-} ight) end{array}]


时间序列的ADF检验:(AIC)--HJC准则 lag length suggested by HJ--平稳性

[mathrm{HJC}=ln left(left|widehat{Omega}_{j} ight| ight)+mathrm{j}left(frac{n^{2} ln T+2 n^{2} ln (ln T)}{2 T} ight), mathrm{j}=0, cdots, mathrm{p} ]

hqc = log(det(VARCOV)) + (2/T)*(M*M*lag_guess + M)*log(log(T)) + M *(1 +log(2*pi));

{lag_length2}

input:矩阵(观测数据),lag length最小值,p为lag length最大值

output: hjclag - Lag length suggested by Hatermi-J criterion.

{hjcA} - Matrix of coefficient estimates 利用 HJC


{VARLAGS}:VAR(2)--根据分类所得的矩阵(两列)

input:lags,矩阵$$d_{max } operatorname{lags}left( ext { i.e., } p=k+d_{max } ight)$$

output:x-根据lag输出input矩阵的一部分(T - lags) x K matrix, the last T-lags rows of var

[Z_{t}:=left(egin{array}{c} 1 \ P_{t}^{+} \ P_{t-1}^{+} \ vdots \ P_{t-p+1}^{+} end{array} ight) ext {for } t=1 ldots, T]


{rstrctvm}:input:VAR()阶数,变量数,addlags--限制系数(Granger Causality in Multi-variate Time Series
using a Time Ordered Restricted Vector Autoregressive Model)

[H_{0}: C eta=0$$,$C$ is a $p*n(1=np)$ 指标符矩阵$$d_{max } operatorname{lags}left( ext { i.e., } p=k+d_{max } ight) ]

----OUTPUT: 只含0/1的矩阵

Rvector1:A 1 indicates which coefficient is 限制到 zero; 0 is given 没有限制

(Rmatrix1)indicator
matrix


{EstVar_Params}:为bootstraps提供数据

[Y^{*}=widehat{D} Z+delta^{*} ]

Ahat:得到所需要的系数参数(widehat{A})

(1)首先在公式(3-37)成立的基础上,估计式(3-33)的系数,将残差保存
下来;
(2)等概率从(1)式保存的残差中抽样,并保证每一组残差样本的均值为 0,
以此方法来获得 bootstrap 样本 (hat{e}_{t});
(3)利用公式 (Y^{*}=hat{Y}_{t}^{+}+hat{e}_{t},) 通过 (1),(2) 估计得到的 (hat{Y}_{t}^{+}, hat{e}_{t},) 可以得到 bootstrap
数据;

leverages:保证恒定的方差

[ ext { at } V=left(Y_{-1}^{prime}, cdots, Y_{-k}^{prime} ight) ext { and } V_{i}=left(Y_{i,-1}^{prime}, cdots, Y_{i,-k}^{prime} ight) ]

[l_{1}=operatorname{diag}left(V_{1}left(V_{1}^{prime} V_{1} ight)^{-1} V_{1}^{prime} ight), ext { and } l_{2}=operatorname{diag}left(Vleft(V^{prime} V ight)^{-1} V^{prime} ight) ]

(H_{0}:) the row (j,) column (k) element in (A_{r}) equals zero for (r=1 ldots, p)


{W_test:}

[ ext { Wald }=(C eta)^{prime}left[C(Z Z)^{-1} otimes S_{U} C ight]^{-1}(C eta) ]

input:y:data matrix based on lag ,x:lagged values for y

Ahat,Rmatrix1--(C)

output: Wstat - vector of Wald statistics(得到的W统计量)


{Bootstrap_Toda}

[V=left(Y_{-1}^{prime}, cdots, Y_{-k}^{prime} ight) ext { and } V_{i}=left(Y_{i,-1}^{prime}, cdots, Y_{i,-k}^{prime} ight) ]

[Y_{-P} ext { to be }left(y_{1-P}, cdots, y_{T-P} ight) ]

(Y_{i,-P}) to be (Y_{-P}) 's ith row.

[d_{max } operatorname{lags}left( ext { i.e., } p=k+d_{max } ight) ]

[y_{t}=hat{gamma}_{0}+hat{gamma}_{1} t+hat{J}_{1} y_{t-1}+cdots+hat{J}_{k} y_{t-k}+hat{J}_{k+1} y_{t-k-1}+hat{J}_{k+2} y_{t-k-2}+hat{varepsilon}_{t} ]

The modified residual for (y_{i t}) is produced as:$$hat{u}{i t}^{m}=frac{hat{u}{i t}}{sqrt{1-l_{i t}}}$$

where the (t) th element of (l_{i}) is given by (l_{i t}) and the raw residual from the regression with (y_{i t}) as the
dependent variable is given by (hat{u}_{i t})

using the previously 确定的最佳 lag order for the original data and an assumed order of integration

假定的整合顺序

DPG(OLS)

[H_{j}=left[egin{array}{cccccc} I_{n} & I_{n} & I_{n} & cdots & I_{n} & I_{n} \ 0 & I_{n} & I_{n} & cdots & I_{n} & I_{n} \ 0 & 0 & I_{n} & cdots & I_{n} & I_{n} \ vdots & vdots & vdots & ddots & vdots & vdots \ 0 & 0 & 0 & cdots & I_{n} & I_{n} \ 0 & 0 & 0 & cdots & 0 & I_{n} end{array} ight]]

The resulting set of bootstrapped Wald statistics is referred to as the bootstrapped Wald distribution[Toda and Yamamoto (1995) methodology]

yhat = Xhat(2:size(Xhat,1),2:(numvars+1));
Xhat = Xhat(1:size(Xhat,1)-1,:);
[AhatTU,unneededleverage] = estvar_params(yhat,Xhat,0,0,order,addlags);%estvar_params
Wstat = W_test(yhat,Xhat,AhatTU,Rmatrix1);

:根据显著值分类0.01/0.005/0.1

    onepct_index = bootsimmax - floor(bootsimmax/100);
    fivepct_index = bootsimmax - floor(bootsimmax/20);
    tenpct_index = bootsimmax - floor(bootsimmax/10);

OUTPUT:
Wcriticalvals - matrix of critical values for Wald statistics(W统计量的临界值--分位点)

WW(leftarrow)[得到的W统计量,W统计量的临界值]

利用循环做不同列的对比,取0/1--代表是否具有格兰特因果关系

原文地址:https://www.cnblogs.com/zonghanli/p/13444135.html