/*-------------------------------------------------------------------- (N.C.M. 1/17/93) COMPAN.SET -- Sets up the companion matrix for a VAR(p) system of m equations. USAGE: A=COMPAN(alpha,m,p); alpha=Coefficient matrix from VAR. m=no. of variables (equations) in system. p=no. of lags in VAR The VAR (and alpha) is assumed to have the following structure -------------------------- y1(t) = [y1(t-1),...,y1(t-p),...ym(t-1),...,ym(t-p)]*alpha[1,.]' y2(t) = [y1(t-1),...,y1(t-p),...ym(t-1),...,ym(t-p)]*alpha[2,.]' ym(t) = [y1(t-1),...,y1(t-p),...ym(t-1),...,ym(t-p)]*alpha[m,.]' -------------------------- Note: If you run a regression and bj is the kx1 vector of least squares coefficients from equation j, set alpha[j,.]=bj', or alpha=b1'|b2'|...|bm'; EXAMPLE PROGRAM: format /m1 6,1; #include compan.set; let b[3,9]= 2 2 2 4 4 4 3 3 3 3 3 3 5 5 5 8 8 8 4 4 4 5 5 5 4 4 4 ; m=3; p=3; a=compan(b,m,p); ---------------------------------------------------------------*/ proc COMPAN(alpha,m,p); local i,a; a=eye(m*p); a=rotater(a,-1); i=0; do while i<=(m-1); a[i*p+1,.]=alpha[i+1,.]; i=i+1; endo; retp(a); endp; /*--------------------------------------------------------*/