Skip to content
Snippets Groups Projects
Commit 4e121fcc authored by Johannes Pfeifer's avatar Johannes Pfeifer
Browse files

set_number_of_subdraws.m: allow for outputting number of draws per chain

parent 3b86307c
No related branches found
No related tags found
1 merge request!2318Make posterior sampling more efficient and enable posterior objects for SMC and DIME
function [sub_draws, error_flag]=set_number_of_subdraws(M_,options_)
% function [sub_draws, error_flag]=set_number_of_subdraws(M_,options_)
function [sub_draws, error_flag, NumberOfDrawsPerChain]=set_number_of_subdraws(M_,options_)
% function [sub_draws, error_flag, NumberOfDrawsPerChain]=set_number_of_subdraws(M_,options_)
% Set option field sub_draws based on size of available sample
% Inputs:
% M_ [structure] Dynare model structure
......@@ -9,6 +9,8 @@ function [sub_draws, error_flag]=set_number_of_subdraws(M_,options_)
% sub_draws [scalar] number of sub-draws
% error_flag [boolean] error indicate of insufficient draws are
% available
% NumberOfDrawsPerChain [integer] number of available posterior draws
% per chain
% Copyright © 2024 Dynare Team
%
......@@ -54,11 +56,13 @@ else
pfiles = dir(sprintf('%s/hssmc/particles-*.mat', M_.dname));
posterior = load(sprintf('%s/hssmc/particles-%u-%u.mat', M_.dname, length(pfiles), length(pfiles)));
NumberOfDraws = size(posterior.particles,2);
NumberOfDrawsPerChain=NumberOfDraws;
elseif isdime(options_)
posterior = load(sprintf('%s%s%s%schains.mat', M_.dname, filesep(), 'dime', filesep()));
tune = posterior.tune;
chains = reshape(posterior.chains(end-tune:end,:,:), [], size(posterior.chains, 3));
NumberOfDraws=size(chains,1);
NumberOfDrawsPerChain=NumberOfDraws;
else
error('set_number_of_subdraws:: case should not happen. Please contact the developers')
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment