FOCUS AREAS

SAS/ETS Examples

Heteroscedastic Two-Stage Least Squares Regression with PROC MODEL


Contents | Back to Example

SAS Program

   /*-----------------------------------------------------------------
     Example: Heteroscedastic Two-Stage Least Squares Regression with PROC MODEL
     Requires: SAS/ETS
     Version: 9.0
     ------------------------------------------------------------------*/


options ls=80;
data klein;
   input year c p w i x wp g t k wsum;
   date=mdy(1,1,year);
   format date monyy.;
   y   =c+i+g-t;
   yr  =year-1931;
   klag=lag(k);
   plag=lag(p);
   xlag=lag(x);
   label year='YEAR                  '
         date='DATE                  '
         c   ='CONSUMPTION           '
         p   ='PROFITS               '
         w   ='PRIVATE WAGE BILL     '
         i   ='INVESTMENT            '
         k   ='CAPITAL STOCK         '
         y   ='NATIONAL INCOME       '
         x   ='PRIVATE PRODUCTION    '
         wsum='TOTAL WAGE BILL       '
         wp  ='GOVT WAGE BILL        '
         g   ='GOVT DEMAND           '
         t   ='TAXES                 '
         klag='CAPITAL STOCK LAGGED  '
         plag='PROFITS LAGGED        '
         xlag='PRIVATE PRODUCT LAGGED'
         yr  ='YEAR-1931             ';
   datalines;
1920     .  12.7     .    .  44.9    .     .     .  182.8     .
1921  41.9  12.4  25.5 -0.2  45.6  2.7   3.9   7.7  182.6  28.2
1922  45.0  16.9  29.3  1.9  50.1  2.9   3.2   3.9  184.5  32.2
1923  49.2  18.4  34.1  5.2  57.2  2.9   2.8   4.7  189.7  37.0
1924  50.6  19.4  33.9  3.0  57.1  3.1   3.5   3.8  192.7  37.0
1925  52.6  20.1  35.4  5.1  61.0  3.2   3.3   5.5  197.8  38.6
1926  55.1  19.6  37.4  5.6  64.0  3.3   3.3   7.0  203.4  40.7
1927  56.2  19.8  37.9  4.2  64.4  3.6   4.0   6.7  207.6  41.5
1928  57.3  21.1  39.2  3.0  64.5  3.7   4.2   4.2  210.6  42.9
1929  57.8  21.7  41.3  5.1  67.0  4.0   4.1   4.0  215.7  45.3
1930  55.0  15.6  37.9  1.0  61.2  4.2   5.2   7.7  216.7  42.1
1931  50.9  11.4  34.5 -3.4  53.4  4.8   5.9   7.5  213.3  39.3
1932  45.6   7.0  29.0 -6.2  44.3  5.3   4.9   8.3  207.1  34.3
1933  46.5  11.2  28.5 -5.1  45.1  5.6   3.7   5.4  202.0  34.1
1934  48.7  12.3  30.6 -3.0  49.7  6.0   4.0   6.8  199.0  36.6
1935  51.3  14.0  33.2 -1.3  54.4  6.1   4.4   7.2  197.7  39.3
1936  57.7  17.6  36.8  2.1  62.7  7.4   2.9   8.3  199.8  44.2
1937  58.7  17.3  41.0  2.0  65.0  6.7   4.3   6.7  201.8  47.7
1938  57.5  15.3  38.2 -1.9  60.9  7.7   5.3   7.4  199.9  45.9
1939  61.6  19.0  41.6  1.3  69.5  7.8   6.6   8.9  201.2  49.4
1940  65.0  21.1  45.0  3.3  75.7  8.0   7.4   9.6  204.5  53.0
1941  69.7  23.5  53.3  4.9  88.4  8.5  13.8  11.6  209.4  61.8
;
run;



   proc model data=klein;
      c=c0 + c1*p + c2*plag + c3*wsum;
      i=i0 + i1*p + i2*plag + i3*klag;
      w=w0 + w1*x + w2*xlag + w3*yr;
   fit c i w /ols;
   title 'OLS results';
   run;
   quit;



   proc model data=klein;
      instruments klag plag xlag wp g t yr;
      c=c0 + c1*p + c2*plag + c3*wsum;
      i=i0 + i1*p + i2*plag + i3*klag;
      w=w0 + w1*x + w2*xlag + w3*yr;
   fit c i w / 2sls outv=vdata vardef=n kernel=(bart,0,);
   title '2sls results';
   run;
   quit;



   data vblkdiag;
     set vdata;
     if (eq_row ^= eq_col) then value=0;   /* make V block-diagonal */

   proc print data=vblkdiag(obs=15);
   title 'Block-diagonal V-matrix';
   run;



   proc model data=klein;
      instruments klag plag xlag wp g t yr;
      c=c0 + c1*p + c2*plag + c3*wsum;
      i=i0 + i1*p + i2*plag + i3*klag;
      w=w0 + w1*x + w2*xlag + w3*yr;
   fit c i w / no2sls gmm vdata=vblkdiag vardef=n nogengmmv;
   title 'H2SLS results';
   run;
   quit;