From 3b86307c2f935570e6a7bb0554a62875702df3d0 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Thu, 3 Oct 2024 12:52:01 +0200
Subject: [PATCH] bug: fix number of sub_draws used

Reverts of https://git.dynare.org/Dynare/dynare/-/commit/5424fde74ede37708a55ca96ef9c8403a371cc29
---
 matlab/estimation/set_number_of_subdraws.m | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/matlab/estimation/set_number_of_subdraws.m b/matlab/estimation/set_number_of_subdraws.m
index 027303d16..a54d187f3 100644
--- a/matlab/estimation/set_number_of_subdraws.m
+++ b/matlab/estimation/set_number_of_subdraws.m
@@ -32,9 +32,10 @@ error_flag=false;
 if ~issmc(options_)
     record=load_last_mh_history_file([M_.dname filesep 'metropolis'], M_.fname);
     TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
-    NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
+    NumberOfDrawsPerChain = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
+    NumberOfDraws=NumberOfDrawsPerChain*record.Nblck;
     if isempty(options_.sub_draws)
-        sub_draws = min(options_.posterior_max_subsample_draws, ceil(.25*NumberOfDraws));
+        sub_draws = min(options_.posterior_max_subsample_draws, ceil(NumberOfDraws));
     else
         if options_.sub_draws>NumberOfDraws*record.Nblck
             skipline()
@@ -62,7 +63,7 @@ else
         error('set_number_of_subdraws:: case should not happen. Please contact the developers')
     end
     if isempty(options_.sub_draws)
-        sub_draws = min(options_.posterior_max_subsample_draws, ceil(.25*NumberOfDraws));
+        sub_draws = min(options_.posterior_max_subsample_draws, NumberOfDraws);
     else
         if options_.sub_draws>NumberOfDraws
             skipline()
-- 
GitLab