/* ** Economic Convergence Model ** using time-dependent economic distance spatial weights */ use gpe2; load wd[29,29]=tsinghua\smatrix.txt; @ w=wd[2:29,2:29]./sumc(wd[2:29,2:29]'); @ @ row-standardized w @ w1=wd[2:29,2:29]; w2=denseSubmat(sparseOnes(spwpower(spw(w1),2),28,28),0,0); w=w1+w2; @ w=w1; @ load y[29,26]=tsinghua\chinay2.txt; @ rpcgdpm.txt @ y=y[2:29,2:26]; t=12; @ select the terminating year: 12=1989, 25=2002 @ @ 16/17 is the break @ /* @ economic distance weights based on y[.,1;t] @ ym=meanc(y[.,1:t]'); @ 28 state average y over 12 (t-11:t) years @ w3=diagrv(1/abs(ym-ym'),zeros(28,1)); w=w3.*w; @ this spatial weights matrix depends on t @ */ w=w./sumc(w'); @ row-standardized w @ _w_=sparseFD(w,0); @ dense matrix w -> sparse matrix _w_ @ _wr=real(eig(w)); print 1/maxc(_wr); print 1/minc(_wr); yt=y[.,t]; @ 25=2002 @ y0=y[.,t-11]; @ 1= 1978 @ yv=ln(yt./y0); wx=sparseTD(_w_,ln(y0)); xv=ln(y0)~ones(rows(yv),1); @ unconditional model @ call sptest1(yv,xv); @ test on ols residuals @ call reset; _nlopt=1; @ 0=weighted NLSQ or 1=MAXLIK @ _method=5; _iter=200; _conv=1; _print=0; b=yv/xv; /* estimate and test various model specifications */ _splag=1; _spar=0; _spma=0; /* if t>16; _splag=1; endif; */ call spestimate(yv,xv,b); call sptest2(yv,xv,__b); @ test on estimated model @ _bjtest=1; _bptest=1; e=sprf(yv~xv,__b); @ call diagnose(yv,xv,e); @ end; #include gpe\spatial.gpe; #include gpe\diagnose.gpe;