From 23f032223612e492ed6d0fc53c1aeac99332fc27 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Tue, 11 Mar 2014 10:05:17 +0100 Subject: [PATCH] Cosmetic changes to documentation of osr --- matlab/osr.m | 23 ++++++++++++++++++++++- matlab/osr1.m | 21 ++++++++++++++------- matlab/osr_obj.m | 10 +++++----- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/matlab/osr.m b/matlab/osr.m index 59ecda15d..d48cd3e67 100644 --- a/matlab/osr.m +++ b/matlab/osr.m @@ -1,5 +1,26 @@ function osr_res = osr(var_list,params,i_var,W) - +% osr_res = osr(var_list,params,i_var,W) +% Wrapper function computing the solution to the optimal simple +% rule-problem; calls osr1 for actual computation +% INPUTS +% var_list [character array] list of endogenous variables specified +% after osr1-command (deprecated and not used anymore) +% params [character array] list of parameter to be chosen in +% optimal simple rule +% i_var [n_osr_vars by 1 double] indices of osr-variable in +% specified in optim_weights in declaration order +% W [M_.endo_nbr by M_.endo_nbr sparse matrix] Weighting matrix for variance of endogenous variables +% +% OUTPUTS +% osr_res: [structure] results structure containing: +% - objective_function [scalar double] value of the objective +% function at the optimum +% - optim_params [structure] parameter values at the optimum +% +% +% SPECIAL REQUIREMENTS +% none. +% % Copyright (C) 2001-2012 Dynare Team % % This file is part of Dynare. diff --git a/matlab/osr1.m b/matlab/osr1.m index c6a617b5b..deba95945 100644 --- a/matlab/osr1.m +++ b/matlab/osr1.m @@ -2,10 +2,21 @@ function osr_res = osr1(i_params,i_var,weights) % Compute the Optimal Simple Rules % INPUTS % i_params vector index of optimizing parameters in M_.params -% i_var vector variables indices +% i_var vector variables indices in declaration order % weights vector weights in the OSRs % -% Copyright (C) 2005-2013 Dynare Team +% OUTPUTS +% osr_res: [structure] results structure containing: +% - objective_function [scalar double] value of the objective +% function at the optimum +% - optim_params [structure] parameter values at the optimum +% +% Algorithm: +% +% Uses Newton-type optimizer csminwel to directly solve quadratic +% osr-problem +% +% Copyright (C) 2005-2014 Dynare Team % % This file is part of Dynare. % @@ -78,8 +89,6 @@ end % [p,f]=fminunc(@osr_obj,t0,options,i_params,... % inv_order_var(i_var),weights(i_var,i_var)); - - skipline() disp('OPTIMAL VALUE OF THE PARAMETERS:') skipline() @@ -88,6 +97,4 @@ for i=1:np end disp(sprintf('Objective function : %16.6g\n',f)); skipline() -[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_); - -% 05/10/03 MJ modified to work with osr.m and give full report \ No newline at end of file +[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_); \ No newline at end of file diff --git a/matlab/osr_obj.m b/matlab/osr_obj.m index 0b9ee73a8..431a941f7 100644 --- a/matlab/osr_obj.m +++ b/matlab/osr_obj.m @@ -78,11 +78,11 @@ switch info(1) case 20 loss = 1e8*min(1e3,info(2)); return - otherwise - if info(1)~=0 - loss = 1e8; - return; - end + otherwise + if info(1)~=0 + loss = 1e8; + return; + end end vx = get_variance_of_endogenous_variables(dr,i_var);