@ COREST.SET @ @------------------------------------------------------------------------------ Prepared by: Lars P. Hansen and Masao Ogaki Department of Economics, University of Chicago Last Revision: 10/18/93 ------------------------------------------------------------------------------@ /* This file defines a procedure to estimate correlations of two stationary time series g(t) and h(t). Syntax: corgh=corest(gh,lend); The output, corgh, is an estimate of the correlation. Input: gh=[g(1),h(1) ..... g(T),h(T)] T by 2 matrix lend: scalar, the lag truncation number for Newey and West method. */ @ ------------------------------------------------------- @ @ Usually the user does not have to modify the code below @ @ ------------------------------------------------------- @ #include "lgmmhet.set"; proc corest(gh,lend); local tend,i,b,varb,varg,varh,corgh,vcor,vg,vh; tend=rows(gh); yp=(gh[.,1].*gh[.,2])~(gh[.,1].^2)~(gh[.,2].^2)~gh[.,1]~gh[.,2]; xxp=ones(tend,1)~zeros(tend,4); i=2; do until i>4; xxp=xxp~zeros(tend,i-1)~ones(tend,1)~zeros(tend,5-i); i=i+1; endo; xxp=xxp~zeros(tend,4)~ones(tend,1); zzp=ones(tend,5); ? "COREST.OUT"; ? "b1=E(gh),b2=E(g^2),b3=E(h^2),b4=E(g),b5=E(h)"; b=lgmmhet(ones(5,1),ones(5,1),0,2,0,3,5,lend); load varb=varb; varg=b[2,1]-b[4,1]^2; varh=b[3,1]-b[5,1]^2; corgh=(b[1,1]-b[4,1]*b[5,1])/sqrt(varg*varh); vcor=(1/sqrt(varg*varh))|(-corgh/(2*varg))|(-corgh/(2*varh))| (corgh*b[4,1]/varg-b[5,1]/sqrt(varg*varh))| (corgh*b[5,1]/varh-b[4,1]/sqrt(varg*varh)); vg=0|1|0|(-2*b[4,1])|0; vh=0|0|1|0|(-2*b[5,1]); ? "correlation of g(t) and h(t)=" corgh; ? "s.e.=" sqrt(vcor'varb*vcor); ? "var(g(t))=" varg; ? "s.e.=" sqrt(vg'varb*vg); ? "var(h(t))=" varh; ? "s.e.=" sqrt(vh'varb*vh); retp(corgh); endp;