From d8a31b985cc1ec22fd28c2f27814ce62990fac3a 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.
(cherry picked from commit 669016167e66992e676b7a06a2a88b7b34b67248)

Conflicts:
	matlab/osr1.m
---
 matlab/osr1.m | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/matlab/osr1.m b/matlab/osr1.m
index d2270546b5..65e1c204e6 100644
--- a/matlab/osr1.m
+++ b/matlab/osr1.m
@@ -88,6 +88,8 @@ end
                 inv_order_var(i_var),weights(i_var,i_var));
 oo_.osr.objective_function = f;
 
+M_.params(i_params)=p; %make sure optimal parameters are set (and not the last draw used in csminwel)
+
 %  options = optimset('fminunc');
 %  options = optimset('display','iter');
 %  [p,f]=fminunc(@osr_obj,t0,options,i_params,...
-- 
GitLab