%COMPHP3   Take ndraw realizations of shocks from RBC model with
%          unit root in technology estimated by MLE with US data.
%          Use them to get ndraw realizations of productivity and 
%          hours.  Compute HP-filtered statistics with the data.
                                                                                
%          Ellen McGrattan, 3-17-04
%          Revised, ERM, 4-15-05


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

% RBC model parameters
gn       = (1.01)^(1/4)-1;
gz       = (1.02)^(1/4)-1;
beta     = .98^(1/4);
delta    = 1-(1-.06)^(1/4);
psi      = 1.6;
sigma    = 1.000001;
theta    = .33;
param    = [gn;gz;beta;delta;psi;sigma;theta];
pu3;

% SVAR settings
alpha    = 0;
p        = 4;
nt       = 101;
ndraw    = 1000;
ldata    = 180;
ndraw    = 1;
ldata    = 100000;
for I=1:ndraw;
  mdata      = drawq3_ur(param,Sbar,P,Q,ldata);
  Y(:,I)     = mdata(:,1).*mdata(:,2);
  H(:,I)     = mdata(:,2);
  YdivH(:,I) = mdata(:,1);
  dy(:,I)    = log(Y(:,I))-hptrend(log(Y(:,I)),1600);
  dh(:,I)    = log(H(:,I))-hptrend(log(H(:,I)),1600);
  dp(:,I)    = log(YdivH(:,I))-hptrend(log(YdivH(:,I)),1600);
end;

