Wednesday, January 20, 2010

Replicating Econbrowser's replication of CEA analysis

There was an interesting post on Econbrowser where the impact of the fiscal stimulus done by the CEA was replicated.

options nocenter;
filename gdp 'C:\ReplicateCEA\GDPC1.txt';
/* File downloaded from FRED St. Louis */
data GDP;
infile gdp firstobs = 14;
/* Read two variables: date and GDP */
input date value;
informat date yymmdd10.;
format date yymmdd10.;
lngdp = log(value);
y=lngdp;
/* Calculate the first difference of y */
diffy = dif(y);
run;

data gdp4q;
set GDP end=last;
output;
if last then do;
date = '01Oct2009'd;
value = value * 1.04;
lngdp = log(value);
y=lngdp;
output;
end;
run;

data gdp4q;
set gdp4q;
dateq = put(date,yyq6.);
run;

filename nfp 'C:SVAR\ReplicateCEA\PAYEMS.txt';
/* File downloaded from FRED St. Louis */
data NFP;
infile nfp firstobs = 16;
/* Read two variables: date and GDP */
input date value;
informat date yymmdd10.;
format date yymmdd10.;
lnnfp = log(value);
e=lnnfp;
/* Calculate the first difference of y */
diffnfp = dif(e);
dateq = put(date,yyq6.);
run;

data nfp2;
set nfp; by dateq date;

if last.dateq then output;
run;

data gdp_nfp(drop = ln: diff:);
merge gdp4q(in=a rename = (value = gdp)) nfp2(in=b rename = (value = nfp));

by dateq;
if a and b;
run;

proc print data = gdp_nfp noobs;
where year(date)>=2007;
run;

ods output ParameterEstimates=pe;
proc varmax data = gdp_nfp;
where 1990<=year(date)<=2007;
id date interval = qtr;
model y e /p=4 ;
output lead=12 out = for;
run;

proc transpose data = pe out = pe_ty;
where equation = 'y';
var estimate;
id parameter;
run;

data pe_ty;
set pe_ty(rename = (const1 = intercept) drop = _name_);
_type_ = 'PARMS';
_model_ = 'Baseline';
_depvar_ = 'y';
y = -1;
RUN;

proc transpose data = pe out = pe_te;
where equation = 'e';
var estimate;
id parameter;
run;

data pe_te;
set pe_te(rename = (const2 = intercept) drop = _name_);
_type_ = 'PARMS';
_model_ = 'Baseline';
_depvar_ = 'e';
e = -1;
RUN;

%macro genar(lag=,eq1=,eq2=,var1=,var2=);
%do i=1 %to &lag;
%do e=1 %to &eq2;
ar&i._&eq1._&e=lag&i(&&var&e);
%end;
%end;
%mend genar;

options mprint;
data gdp2;
set gdp_nfp;
%genar(lag=4,eq1=1,eq2=2,var1=y,var2=e);
run;

data e2;
set gdp_nfp;
%genar(lag=4,eq1=2,eq2=2,var1=y,var2=e);
run;

proc score data = gdp2 score = pe_ty out=gdp2_score type=parms;
var ar1_1_1 ar1_1_2 ar2_1_1 ar2_1_2 ar3_1_1 ar3_1_2 ar4_1_1 ar4_1_2;
run;

proc score data = e2 score = pe_te out=e2_score type=parms;
var ar1_2_1 ar1_2_2 ar2_2_1 ar2_2_2 ar3_2_1 ar3_2_2 ar4_2_1 ar4_2_2;
run;

symbol1 value=none i=join;
symbol2 value=none i=join;
proc gplot data = gdp2_Score;
where year(date)>=2008;
plot (baseline y) * date / overlay;
run;
quit;

proc gplot data = e2_score;
where year(date)>=2008;
plot (baseline e) * date / overlay;
run;
quit;

No comments: