thet2tau.m 1.15 KB
Newer Older
rattoma's avatar
rattoma committed
1
function tau = thet2tau(params, indx, indexo, flagmoments,mf,nlags,useautocorr)
rattoma's avatar
rattoma committed
2
global M_ oo_ options_
rattoma's avatar
rattoma committed
3
4
5

if nargin==1,
    indx = [1:M_.param_nbr];
rattoma's avatar
rattoma committed
6
    indexo = [];
rattoma's avatar
rattoma committed
7
8
end

rattoma's avatar
rattoma committed
9
if nargin<4,
rattoma's avatar
rattoma committed
10
11
  flagmoments=0;
end
rattoma's avatar
rattoma committed
12
13
14
if nargin<7 | isempty(useautocorr),
  useautocorr=0;
end
rattoma's avatar
rattoma committed
15

rattoma's avatar
rattoma committed
16
17
18
19
M_.params(indx) = params(length(indexo)+1:end);
if ~isempty(indexo)
  M_.Sigma_e(indexo,indexo) = diag(params(1:length(indexo)).^2);
end
rattoma's avatar
rattoma committed
20
% [A(oo_.dr.order_var,oo_.dr.order_var),B(oo_.dr.order_var,:)]=dynare_resolve;
21
[A,B,plouf,plouf,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
rattoma's avatar
rattoma committed
22
if flagmoments==0,
rattoma's avatar
rattoma committed
23
tau = [oo_.dr.ys(oo_.dr.order_var); A(:); dyn_vech(B*M_.Sigma_e*B')];
rattoma's avatar
rattoma committed
24
25
else
GAM =  lyapunov_symm(A,B*M_.Sigma_e*B',options_.qz_criterium,options_.lyapunov_complex_threshold);
rattoma's avatar
rattoma committed
26
27
k = find(abs(GAM) < 1e-12);
GAM(k) = 0;
rattoma's avatar
rattoma committed
28
29
30
31
32
if useautocorr,
  sy = sqrt(diag(GAM));
  sy = sy*sy';
  sy0 = sy-diag(diag(sy))+eye(length(sy));
  dum = GAM./sy0;
rattoma's avatar
rattoma committed
33
  tau = dyn_vech(dum(mf,mf));
rattoma's avatar
rattoma committed
34
else
rattoma's avatar
rattoma committed
35
  tau = dyn_vech(GAM(mf,mf));
rattoma's avatar
rattoma committed
36
end
rattoma's avatar
rattoma committed
37
38
for ii = 1:nlags
  dum = A^(ii)*GAM;
rattoma's avatar
rattoma committed
39
40
41
42
  if useautocorr,
    dum = dum./sy;
  end
  tau = [tau;vec(dum(mf,mf))];
rattoma's avatar
rattoma committed
43
end
rattoma's avatar
rattoma committed
44
tau = [ oo_.dr.ys(oo_.dr.order_var(mf)); tau];
rattoma's avatar
rattoma committed
45
end