


Copyright (C) 2005-2011 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 <http://www.gnu.org/licenses/>.


0001 function osr1(i_params,i_var,weights) 0002 0003 % Copyright (C) 2005-2011 Dynare Team 0004 % 0005 % This file is part of Dynare. 0006 % 0007 % Dynare is free software: you can redistribute it and/or modify 0008 % it under the terms of the GNU General Public License as published by 0009 % the Free Software Foundation, either version 3 of the License, or 0010 % (at your option) any later version. 0011 % 0012 % Dynare is distributed in the hope that it will be useful, 0013 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0015 % GNU General Public License for more details. 0016 % 0017 % You should have received a copy of the GNU General Public License 0018 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0019 0020 global M_ oo_ options_ it_ 0021 0022 klen = M_.maximum_lag + M_.maximum_lead + 1; 0023 iyv = M_.lead_lag_incidence'; 0024 iyv = iyv(:); 0025 iyr0 = find(iyv) ; 0026 it_ = M_.maximum_lag + 1 ; 0027 0028 0029 if M_.exo_nbr == 0 0030 oo_.exo_steady_state = [] ; 0031 end 0032 0033 if ~ M_.lead_lag_incidence(M_.maximum_lag+1,:) > 0 0034 error ('OSR: Error in model specification: some variables don''t appear as current') ; 0035 end 0036 0037 if M_.maximum_lead == 0 0038 error ('Backward or static model: no point in using OSR') ; 0039 end 0040 0041 exe =zeros(M_.exo_nbr,1); 0042 0043 oo_.dr = set_state_space(oo_.dr,M_); 0044 0045 0046 np = size(i_params,1); 0047 t0 = M_.params(i_params); 0048 inv_order_var = oo_.dr.inv_order_var; 0049 0050 H0 = 1e-4*eye(np); 0051 crit = 1e-7; 0052 nit = 1000; 0053 verbose = 2; 0054 0055 [f,p]=csminwel1('osr_obj',t0,H0,[],crit,nit,options_.gradient_method,options_.gradient_epsilon,i_params,... 0056 inv_order_var(i_var),weights(i_var,i_var)); 0057 oo_.osr.objective_function = f; 0058 0059 % options = optimset('fminunc'); 0060 % options = optimset('display','iter'); 0061 % [p,f]=fminunc(@osr_obj,t0,options,i_params,... 0062 % inv_order_var(i_var),weights(i_var,i_var)); 0063 0064 0065 0066 disp('') 0067 disp('OPTIMAL VALUE OF THE PARAMETERS:') 0068 disp('') 0069 for i=1:np 0070 disp(sprintf('%16s %16.6g\n',M_.param_names(i_params(i),:),p(i))) 0071 end 0072 disp(sprintf('Objective function : %16.6g\n',f)); 0073 disp(' ') 0074 [oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_); 0075 0076 % 05/10/03 MJ modified to work with osr.m and give full report