From 669016167e66992e676b7a06a2a88b7b34b67248 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx,de>
Date: Mon, 3 Nov 2014 18:01:04 +0100
Subject: [PATCH] Fix bug in osr where moments were not based on optimal
 parameter draw

M_.params is global and was set by csminwel1 to the last value tested; this does not necessarily coincide with the optimal parameter vector, which may have occurred earlier. This commit explicitly sets the optimal parameter vector.
---
 matlab/osr1.m | 1 +
 1 file changed, 1 insertion(+)

diff --git a/matlab/osr1.m b/matlab/osr1.m
index f964871e1..eb23312ff 100644
--- a/matlab/osr1.m
+++ b/matlab/osr1.m
@@ -97,6 +97,7 @@ end
 [f,p]=csminwel1('osr_obj',t0,H0,[],crit,nit,options_.gradient_method,options_.gradient_epsilon,i_params,...
                 inv_order_var(i_var),weights(i_var,i_var));
 osr_res.objective_function = f;
+M_.params(i_params)=p; %make sure optimal parameters are set (and not the last draw used in csminwel)
 for i=1:length(i_params)
     osr_res.optim_params.(deblank(M_.param_names(i_params(i),:))) = p(i);
 end
-- 
GitLab