From 45bc5c24597416681f7d6eec9615878780a4b809 Mon Sep 17 00:00:00 2001 From: Marco Ratto Date: Fri, 8 Jun 2012 14:03:40 +0200 Subject: [PATCH] Removed duplicate of the same function. Fixed call removing globals. global options_ still needed --- matlab/getH.m | 2 +- matlab/getJJ.m | 4 +-- matlab/gsa/thet2tau.m | 62 ------------------------------------------- matlab/thet2tau.m | 8 +++--- 4 files changed, 7 insertions(+), 69 deletions(-) delete mode 100644 matlab/gsa/thet2tau.m diff --git a/matlab/getH.m b/matlab/getH.m index 71a012437..3e541c659 100644 --- a/matlab/getH.m +++ b/matlab/getH.m @@ -338,7 +338,7 @@ if kronflag==1, % kronecker products elseif kronflag==-1, % perturbation fun = 'thet2tau'; params0 = M_.params; - H = fjaco(fun,[sqrt(diag(M_.Sigma_e(indexo,indexo))); M_.params(indx)],indx,indexo); + H = fjaco(fun,[sqrt(diag(M_.Sigma_e(indexo,indexo))); M_.params(indx)], M_, oo_, indx, indexo); assignin('base','M_', M_); assignin('base','oo_', oo_); diff --git a/matlab/getJJ.m b/matlab/getJJ.m index b6e6805a9..859edf0da 100644 --- a/matlab/getJJ.m +++ b/matlab/getJJ.m @@ -28,10 +28,10 @@ warning('off','MATLAB:divideByZero') if kronflag == -1, fun = 'thet2tau'; params0 = M_.params; - JJ = fjaco(fun,[sqrt(diag(M_.Sigma_e(indexo,indexo))); M_.params(indx)],indx,indexo,1,mf,nlags,useautocorr); + JJ = fjaco(fun,[sqrt(diag(M_.Sigma_e(indexo,indexo))); M_.params(indx)],M_, oo_, indx,indexo,1,mf,nlags,useautocorr); M_.params = params0; params0 = M_.params; - H = fjaco(fun,[sqrt(diag(M_.Sigma_e(indexo,indexo))); M_.params(indx)],indx,indexo,0,mf,nlags,useautocorr); + H = fjaco(fun,[sqrt(diag(M_.Sigma_e(indexo,indexo))); M_.params(indx)],M_, oo_, indx,indexo,0,mf,nlags,useautocorr); M_.params = params0; assignin('base','M_', M_); assignin('base','oo_', oo_); diff --git a/matlab/gsa/thet2tau.m b/matlab/gsa/thet2tau.m deleted file mode 100644 index 7ebdd1a89..000000000 --- a/matlab/gsa/thet2tau.m +++ /dev/null @@ -1,62 +0,0 @@ -function tau = thet2tau(params, indx, indexo, flagmoments,mf,nlags,useautocorr) - -% Copyright (C) 2012 Dynare Team -% -% This file is part of Dynare. -% -% Dynare is free software: you can redistribute it and/or modify -% it under the terms of the GNU General Public License as published by -% the Free Software Foundation, either version 3 of the License, or -% (at your option) any later version. -% -% Dynare is distributed in the hope that it will be useful, -% but WITHOUT ANY WARRANTY; without even the implied warranty of -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% GNU General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with Dynare. If not, see . - -global M_ oo_ options_ - -if nargin==1, - indx = [1:M_.param_nbr]; - indexo = []; -end - -if nargin<4, - flagmoments=0; -end -if nargin<7 | isempty(useautocorr), - useautocorr=0; -end - -M_.params(indx) = params(length(indexo)+1:end); -if ~isempty(indexo) - M_.Sigma_e(indexo,indexo) = diag(params(1:length(indexo)).^2); -end -[A,B,plouf,plouf,M_,options_,oo_] = dynare_resolve(M_,options_,oo_); -if flagmoments==0, -tau = [oo_.dr.ys(oo_.dr.order_var); A(:); dyn_vech(B*M_.Sigma_e*B')]; -else -GAM = lyapunov_symm(A,B*M_.Sigma_e*B',options_.qz_criterium,options_.lyapunov_complex_threshold); -k = find(abs(GAM) < 1e-12); -GAM(k) = 0; -if useautocorr, - sy = sqrt(diag(GAM)); - sy = sy*sy'; - sy0 = sy-diag(diag(sy))+eye(length(sy)); - dum = GAM./sy0; - tau = dyn_vech(dum(mf,mf)); -else - tau = dyn_vech(GAM(mf,mf)); -end -for ii = 1:nlags - dum = A^(ii)*GAM; - if useautocorr, - dum = dum./sy; - end - tau = [tau;vec(dum(mf,mf))]; -end -tau = [ oo_.dr.ys(oo_.dr.order_var(mf)); tau]; -end \ No newline at end of file diff --git a/matlab/thet2tau.m b/matlab/thet2tau.m index 2ae5b2c5c..a59b374b8 100644 --- a/matlab/thet2tau.m +++ b/matlab/thet2tau.m @@ -1,4 +1,4 @@ -function tau = thet2tau(params, indx, indexo, flagmoments,mf,nlags,useautocorr) +function tau = thet2tau(params, M_, oo_, indx, indexo, flagmoments,mf,nlags,useautocorr) % % Copyright (C) 2011 Dynare Team @@ -18,17 +18,17 @@ function tau = thet2tau(params, indx, indexo, flagmoments,mf,nlags,useautocorr) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -global M_ oo_ options_ +global options_ if nargin==1, indx = [1:M_.param_nbr]; indexo = []; end -if nargin<4, +if nargin<6, flagmoments=0; end -if nargin<7 || isempty(useautocorr), +if nargin<9 || isempty(useautocorr), useautocorr=0; end