Granger Causality
取阈值:首先进行回归分析,然后得到的参数,进行排序,根据极端冲击,负极端取0.1,正极端取0.9,作为相应变量的阈值
10个类别(9个是积极,正常,消极的组合,剩下一个是传统格兰特方法)
{shockprc:分类}
时间序列的ADF检验:(AIC)--HJC准则 lag length suggested by HJ--平稳性
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(\text { i.e., } p=k+d_{\max }\right)$$
output:x-根据lag输出input矩阵的一部分(T - lags) x K matrix, the last T-lags rows of var
{rstrctvm}:input:VAR()阶数,变量数,addlags--限制系数(Granger Causality in Multi-variate Time Series
using a Time Ordered Restricted Vector Autoregressive Model)
----OUTPUT: 只含0/1的矩阵
Rvector1:A 1 indicates which coefficient is 限制到 zero; 0 is given 没有限制
(Rmatrix1)indicator
matrix
{EstVar_Params}:为bootstraps提供数据
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:保证恒定的方差
\(H_{0}:\) the row \(j,\) column \(k\) element in \(A_{r}\) equals zero for \(r=1 \ldots, p\)
{W_test:}
input:y:data matrix based on lag ,x:lagged values for y
Ahat,Rmatrix1--\(C\)
output: Wstat - vector of Wald statistics(得到的W统计量)
{Bootstrap_Toda}
\(Y_{i,-P}\) to be \(Y_{-P}\) 's ith row.
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)
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--代表是否具有格兰特因果关系