Hi all,
I have found the following GAUSS code written by Zivot and Lo which conducts
an LR test for 1 versus 3 regimes
http://wueconb.wustl.edu/jda/md/2001-v5.4/lo-zivot/readme I would like to
know if it is possible to run this on OXGauss. In particular can I use
"Include" to call the other procedures. The _qmin is also giving me errors.
Any suggestions are appreciated. Thanks
Declan O Connor
Department of Food Business and Development
University College Cork
Western Road
Cork City
Ireland
Tel +353 21 4903348.
fax +353 21 4903358
/* tvecm3.prc
** estimate TVECM(1) and TVECM(3) models and tests H0: TVECM(1) against
** H1: TVECM(3)
**
** format {Ahat3,seAhat3,lndet3,sigtar,ghat1,ghat2,dhat,n1,n2,n3,lr31}
** = _tvecm3(z,b,p)
**
** inputs z data matrix
** b cointegrating vector
** p lags of 1st differences in VECM
**
** outputs Ahat3 coefficients
** seAhat3 std. errors of the coefficients
** lndet3 ln(det(omega))
** sigtar var-cov matrix of residuals
** ghat1 threshold level 1
** ghat2 threshold level 2
** dhat delay variable
** n1 no. of observations in regime 1
** n2 no. of obs. in regime 2
** n3 no. of obs. in regime 3
** lr31 LR statistics
**
** globals _dmin,dmax,_trim,_qnum
**
** external procedures qsort, qfuncv, _varlags, _tr
**
** comments
** code is based on programs used in Hansen (1999), "Testing Linearity"
** last updated: Sept 6, 1999 by Eric Zivot
*/
proc(11)=_tvecm3(z,b,p);
local n,tt,dz,ecm1,thres,j,y,ylags,t,x,k,e,sighat1,lndet1;
local q,qd,d1,d2,d3,n1,n2,n3,xx,mxx,etar,sigtar;
local dhat,ghat1,ghat2,delay,ahat3,eetar,seahat3,lndet3,lr31;
n=cols(z);
if rows(b)/=n;
"b is not the right dimension, try again";
retp(0,0,0,0,0,0,0,0,0,0,0);
endif;
TT=rows(z); @ # total obvs @
dz=z[2:TT,.]-z[1:TT-1,.]; @ 1st difference in z @
ecm1=z[p+1:TT-1,.]*b; @ lagged error correction term @
@ adjusted for VAR
lags @
thres = ecm1; @ threshold var = ecm term @
j=2; do while j<=p; @ loop to create matrix of
lags @
thres=thres~z[p+2-j:TT-j,.]*b; @ for threshold values when d>1 @
j=j+1;
endo;
if p >=1;
{Y,Ylags}=_varlags(dz,p); @ generating lags @
T=rows(Y); @ # of usable obs @
X=ones(T,1)~ecm1~ylags; @ unrestricted data matrix @
else; @ no lagged 1st
differences @
Y=dz;
T=rows(Y);
X=ones(T,1)~ecm1;
endif;
k=cols(x);
/* estimate TVECM */
e=y-x*(y/x); @ TVECM residuals @
sighat1=e'e/t; @ TVECM covariance @
lndet1=ln(det(sighat1));
/* estimate tvecm(3) using estimated threshold values */
{dhat,ghat1,ghat2} = _vtar3bai(y,x,thres);
q = qfuncv(thres); @ select possible threshold values @
qd=q[.,dhat]; @ threshold values based on
dhat @
delay=_dmin-1+dhat; @ estimated delay @
d1=(qd.<=ghat1); @ obvs in (lower) 1st regime @
d2=(qd.<=ghat2).*(1-d1); @ obvs in (middle) 2nd regime @
d3=1-d1-d2; @ obvs in (upper) 3rd regime @
xx=(x.*d1)~(x.*d2)~(x.*d3); @ data matrix @
mxx=invpd(moment(xx,0)); @ (x'x)^-1 @
Ahat3=mxx*(xx'y); @ ols estimates @
etar=y-xx*ahat3; @ residuals @
eetar=etar'etar; @ unrestricted ssr @
sigtar=eetar/t; @ ols error variance @
seAhat3 = sqrt(diag(Sigtar.*.invpd(XX'XX))); @ OLS standard errors @
seAhat3 = reshape(seAhat3,n,3*(n*p+2))';
n1=sumc(d1);n2=sumc(d2);n3=sumc(d3); @ of obvs in each regime @
lndet3=ln(det(sigtar)); @ log determinant of TVECM(3) @
lr31=t*(lndet1-lndet3); @ lr stat for testing TVECM vs @
@ TVECM(3) @
retp(Ahat3,seAhat3,lndet3,sigtar,ghat1,ghat2,delay,n1,n2,n3,lr31);
endp;
|