Resources

Getting Started Example for PROC VARMAX

/*--------------------------------------------------------------

                    SAS Sample Library

        Name: vargs.sas
 Description: Example program from SAS/ETS User's Guide,
              The VARMAX Procedure
       Title: Getting Started Example for PROC VARMAX
     Product: SAS/ETS Software
        Keys: Vector AutoRegressive Moving-Average
              processes with eXogenous regressors
        PROC: VARMAX
       Notes:

--------------------------------------------------------------*/

proc iml;
   sig = {1.0  0.5, 0.5 1.25};
   phi = {1.2 -0.5, 0.6 0.3};
   /* simulate the vector time series */
   call varmasim(y,phi) sigma = sig n = 100 seed = 34657;
   cn = {'y1' 'y2'};
   create simul1 from y[colname=cn];
   append from y;
quit;

data simul1;
   set simul1;
   date = intnx( 'year', '01jan1900'd, _n_-1 );
   format date year4.;
run;

ods graphics on;

proc timeseries data=simul1 vectorplot=series;
   id date interval=year;
   var y1 y2;
run;

/*--- Vector Autoregressive Model ---*/

proc varmax data=simul1;
   id date interval=year;
   model y1 y2 / p=1 noint lagmax=3
                 print=(estimates diagnose);
   output out=for lead=5;
run;

/*--- Bayesian Vector Autoregressive Process ---*/

proc varmax data=simul1;
   model y1 y2 / p=1 noint
                 prior=(lambda=0.9 theta=0.1);
run;

proc iml;
   sig = 100*i(2);
   phi = {-0.2 0.1, 0.5 0.2, 0.8 0.7, -0.4 0.6};
   call varmasim(y,phi) sigma=sig n=100 initial=0
                        seed=45876;
   cn = {'y1' 'y2'};
   create simul2 from y[colname=cn];
   append from y;
quit;

data simul2;
   set simul2;
   date = intnx( 'year', '01jan1900'd, _n_-1 );
   format date year4. ;
run;

proc timeseries data=simul2 vectorplot=series;
   id date interval=year;
   var y1 y2;
run;

/*--- Cointegration Test ---*/

proc varmax data=simul2;
   model y1 y2 / p=2 noint dftest cointtest=(johansen);
run;

/*--- Vector Error-Correction Model ---*/

proc varmax data=simul2;
   model y1 y2 / p=2 noint lagmax=3
                 ecm=(rank=1 normalize=y1)
                 print=(iarr estimates);
run;

/*--- Bayesian Vector Error-Correction Model ---*/

proc varmax data=simul2;
   model y1 y2 / p=2 noint
                 prior=( lambda=0.5 theta=0.2 )
                 ecm=( rank=1 normalize=y1 )
                 print=(estimates);
run;



data grunfeld;
   input year y1 y2 y3 x1 x2 x3;
   label y1='Gross Investment GE'
         y2='Capital Stock Lagged GE'
         y3='Value of Outstanding Shares GE Lagged'
         x1='Gross Investment W'
         x2='Capital Stock Lagged W'
         x3='Value of Outstanding Shares Lagged W';
datalines;
1935  33.1 1170.6  97.8 12.93  191.5   1.8
1936  45.0 2015.8 104.4 25.90  516.0    .8
1937  77.2 2803.3 118.0 35.05  729.0   7.4
1938  44.6 2039.7 156.2 22.89  560.4  18.1
1939  48.1 2256.2 172.6 18.84  519.9  23.5
1940  74.4 2132.2 186.6 28.57  628.5  26.5
1941 113.0 1834.1 220.9 48.51  537.1  36.2
1942  91.9 1588.0 287.8 43.34  561.2  60.8
1943  61.3 1749.4 319.9 37.02  617.2  84.4
1944  56.8 1687.2 321.3 37.81  626.7  91.2
1945  93.6 2007.7 319.6 39.27  737.2  92.4
1946 159.9 2208.3 346.0 53.46  760.5  86.0
1947 147.2 1656.7 456.4 55.56  581.4 111.1
1948 146.3 1604.4 543.4 49.56  662.3 130.6
1949  98.3 1431.8 618.3 32.04  583.8 141.8
1950  93.5 1610.5 647.4 32.24  635.2 136.7
1951 135.2 1819.4 671.3 54.38  723.8 129.7
1952 157.3 2079.7 726.1 71.78  864.1 145.5
1953 179.5 2371.6 800.3 90.08 1193.5 174.8
1954 189.6 2759.9 888.9 68.60 1188.9 213.5
;

/*--- Vector Autoregressive Process with Exogenous Variables ---*/

proc varmax data=grunfeld;
   model y1-y3 = x1 x2 / p=1 lagmax=5
                         printform=univariate
                         print=(impulsx=(all) estimates);
run;

/*--- Models with Restrictions and Tests ---*/

proc varmax data=grunfeld;
   model y1-y3 = x1 x2 / p=1 print=(estimates);
   restrict XL(0,1,2)=0, AR(1,1,2)=0, AR(1,3,2)=0;
run;

proc varmax data=grunfeld;
   model y1-y3 = x1 x2 / p=1;
   test AR(1,3,1)=0;
   test XL(0,1,2)=0, AR(1,1,2)=0, AR(1,3,2)=0;
run;

/*--- Causality Testing ---*/

proc varmax data=grunfeld;
   model y1-y3 = x1 x2 / p=1 noprint;
   causal group1=(x1) group2=(y1-y3);
   causal group1=(y3) group2=(y1 y2);
run;