资源简介
压缩包内为格兰杰非线性因果关系检验,针对非线性关系,包括C语言和MATLAB语言代码,亲测可用,欢迎下载~
代码片段和文件信息
/*
* This program calculates p-values for the Hiemstra-Jones statistic
* as well as for the Diks-Panchenko statistic. For details see the
* README file and our paper:
*
* Diks C. and Panchenko V. (2006)
* A new statistic and practical guidelines for nonparametric Granger causality
* testing Journal of Economic Dynamics and Control 30 (9-10) 1647-1669
*
* Cees Diks -- June 2008
*/
#include
#include
#include
#define max(ab) a>b?a:b
#define EPS 1.5
int Ndat=15000;
int Mmax=8; /* maximum emb. dim. */
int n K;
double T2QQad**AC[4]*h*ohm*cov;
double p_HJ p_T2 p_HJad HJ_TVAL T2_TVAL;
/* determine the log of ratios of correlation integrals */
void redun(double *x double *y int N int m int mmax double epsilon)
{
int i j s;
int IYij IXYij IYZij IXYZij;
double disx disy disz *Cy *Cxy *Cyz *Cxyz tCy=0 tCxy=0 tCyz=0 tCxyz=0;
Cy = (double *) malloc(N*sizeof(double));
Cxy = (double *) malloc(N*sizeof(double));
Cyz = (double *) malloc(N*sizeof(double));
Cxyz = (double *) malloc(N*sizeof(double));
for (i=0;i!=N;i++)
h[i] = Cy[i] = Cxy[i] = Cyz[i] = Cxyz[i] = 0.0;
T2=Q=0.0;
n = N - mmax;
for (i=mmax;i!=N;i++)
{
Cy[i]=Cxy[i]=Cyz[i]=Cxyz[i]=0.0;
for (j=mmax;j!=N;j++)
if (j!=i)
{
disx = disy = 0.0;
for (s=1;s!=m+1;s++)
disx = max(fabs(x[i-s]-x[j-s])disx);
for (s=1;s!=mmax+1;s++)
disy = max(fabs(y[i-s]-y[j-s])disy);
if (disy <= epsilon)
{
Cy[i]++;
A[3][i]++;
if (disx <= epsilon)
{
Cxy[i]++;
A[1][i]++;
}
disz = max(fabs(y[i]-y[j])disy);
if (disz <= epsilon)
{
Cyz[i]++;
A[2][i]++;
if (disx <= epsilon)
{
Cxyz[i]++;
A[0][i]++;
}
}
} /* end condition |Yi - Yj| < epsilon */
} /* end loop over j */
Cy[i] /= (double)(n);
Cxy[i] /= (double)(n);
Cyz[i] /= (double)(n);
Cxyz[i] /= (double)(n);
h[i] += 2.0*(Cxyz[i]*Cy[i] - Cxy[i]*Cyz[i])/6.0;
for (j=mmax;j!=N;j++)
if (j!=i)
{
IYij = IXYij = IYZij = IXYZij = 0;
disx = disy = 0.0;
for (s=1;s!=m+1;s++)
disx = max(fabs(x[i-s]-x[j-s])disx);
for (s=1;s!=mmax+1;s++)
disy = max(fabs(y[i-s]-y[j-s])disy);
if (disy <= epsilon)
{
IYij=1;
if (disx <= epsilon)
{
IXYij = 1;
}
disz = max(fabs(y[i]-y[j])disy);
if (disz <= epsilon)
{
IYZij = 1;
if (disx <= epsilon)
IXYZij = 1;
}
} /* end condition |Yi - Yj| < epsilon */
h[j] += 2.0*(Cy[i]*IXYZij - Cyz[i]*IXYij)/(double)(6*n);
h[j] += 2.0*(Cxyz[i]*IYij - Cxy[i]*IYZij)/(double)(6*n);
} /* end second loop over j */
tCy+=n*Cy[i]; tCxy+=n*Cxy[i] tCyz+=n*Cyz[i] tCxyz+=n*Cx
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2008-06-04 11:51 hjt2\
文件 1804 2008-06-04 11:50 hjt2\README
目录 0 2008-07-28 14:22 hjt2\c-code\
文件 57 2008-06-04 11:51 hjt2\c-code\Makefile
文件 10862 2008-06-04 11:51 hjt2\c-code\hjt2_tval.c
目录 0 2008-06-04 11:50 hjt2\matlab\
文件 175202 2008-06-04 11:51 hjt2\matlab\spx_rp.dat
文件 174522 2008-06-04 11:51 hjt2\matlab\spx_ur.dat
文件 174522 2008-06-04 11:51 hjt2\matlab\spx_uv.dat
文件 175202 2008-06-04 11:51 hjt2\matlab\spx_vp.dat
文件 498579 2008-06-04 11:51 hjt2\matlab\spx.csv
文件 2613 2008-06-04 11:51 hjt2\matlab\var_resid.m
文件 226 2008-06-04 11:51 hjt2\matlab\delayvectors.m
文件 1649 2008-06-04 11:51 hjt2\matlab\deseason.m
文件 174522 2008-06-04 11:51 hjt2\matlab\spx_uer.dat
文件 174522 2008-06-04 11:51 hjt2\matlab\spx_uev.dat
文件 23775 2008-06-04 11:51 hjt2\c-code\hjt2_tval
文件 31362 2008-10-12 16:36 hjt2\c-code\hjt2_tval.exe
文件 3803 2008-09-25 14:35 hjt2\c-code\x.dat
文件 3806 2008-09-25 14:35 hjt2\c-code\y.dat
文件 2333 2008-09-25 14:35 hjt2\c-code\x_y.sample.out
- 上一篇:骑士周游列国(跳马问题)C++代码实现
- 下一篇:MFC 动态曲线 支持缩放
评论
共有 条评论