%MOVIES    Take 1 realization of shocks from RBC model with 2
%          orthogonal shocks and a unit root in technology.
%          Apply SVAR filters for various lag lengths to see if 
%          true impulse responses can be detected.
                                                                                
%          Ellen McGrattan, 3-17-04
%          Revised, ERM, 9-13-04


% Initialize random seeds
randn('seed',1004)
rand('seed',912)

% RBC model parameters and simulation
gn      = (1.01)^(1/4)-1;
gz      = (1.02)^(1/4)-1;
beta    = .98^(1/4);
delta   = 1-(1-.06)^(1/4);
psi     = 2.5;
sigma   = 1.000001;
theta   = .33;
param   = [gn;gz;beta;delta;psi;sigma;theta];
pq      = 1;    
if pq==1; pu;  end;  % load Sbar,P,Q for dataset PU
if pq==2; fr1; end;  % load Sbar,P,Q for dataset FR1
if pq==3; fr2; end;  % load Sbar,P,Q for dataset F-R2
if pq==4; cev; end;  % load Sbar,P,Q for dataset CEV
if pq==5; gr;  end;  % load Sbar,P,Q for dataset GR

ldata   = 100000;
mdata   = drawq_ur(param,Sbar,P,Q,ldata);
prd     = mdata(:,1);
hpc     = mdata(:,2);

% SVAR settings
alpha   = 0;
nt      = 101;
lags    = [4,10,20,30,40,50,100,200,300];
lags=4;
nlags   = length(lags);

for I=1:nlags;
disp(lags(I))
  p           = lags(I);
  IR          = impreschk(mdata,alpha,p,nt,1);
  Prd_ir(:,I) = IR(:,1);
  Hrs_ir(:,I) = IR(:,2);
end;

figure(1)
plot(Prd_ir)
title('Impulse reponse of productivity to technology shock')
figure(3)
plot(Hrs_ir,'-o')
title('Impulse reponse of hours to technology shock')

