%CGG     Generate figures of interest rates using Clarida, Gali,
%        and Gertler's estimates of Taylor Rule.

% DATA:
%   Monthly Federal Funds Rate,  1955:01-1999:02
%   Quarterly Real GDP, 1992 $,  1947:1 -1998:4
%   Quarterly Deflator (92=100), 1947:1 -1998:4
%
%   Note: CGG's Sample is 1979:3-1996:4

load fyff.dat  
load gdpq.dat  
load gdpd.dat  

r     = fyff(292:3:507,2);
nt    = length(r);
rl    = fyff(289:3:504,2);

y     = gdpq(130:201,2);
ly    = log(y);
pi    = ((gdpd(131:202,2)./gdpd(130:201,2)).^4-1)*100;
o     = ones(nt,1);
trend = [1:nt]';
b     = ols([o,trend,trend.^2],ly);
dy    = 100*(ly-[o,trend,trend.^2]*b);
t     = ptime(1979.2,nt,4);
rcgg  = .79*rl+.21*(2.15*pi+.93*dy)+mean(r-.79*rl-.21*(2.15*pi-.93*dy));

% Actual and Predicted interest rates:

figure(1)
plot(t,r,t,rcgg);
title('Actual and Predicted Federal Funds Rate Using CGG Estimates')
epsr  = r-rcgg;

[b,s] = ols([rl,pi,dy,o],r);
rols  = [rl,pi,dy,o]*b;
figure(2)
plot(t,r,t,rols)
title('Actual and Predicted Federal Funds Rate Using OLS Estimates')

