Skip to content
Snippets Groups Projects
Verified Commit b438c177 authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Add plot (SMC distributions).

parent 6d445eb7
No related branches found
Tags v1.0
No related merge requests found
*.pdf
tex/auto
\ No newline at end of file
tex/auto
model/+fs2000/
model/fs2000/
model/fs2000.log
function particles = load_all_distributions(modelname, nparticles, idparam)
% (C) Stéphane Adjemian 2024
n = number_of_smc_files(modelname);
particles = NaN(nparticles, n);
for i=1:n
p = load(sprintf('%s%shssmc%sparticles-%u-%u.mat', modelname, filesep, filesep, i, n));
particles(:,i) = transpose(p.particles(idparam,:));
end
function p = load_posterior_draws(modelname)
% (C) Stéphane Adjemian 2024
n = number_of_smc_files(modelname);
p = load(sprintf('%s%shssmc%sparticles-%u-%u.mat', modelname, filesep, filesep, n, n));
function n = number_of_smc_files(modelname)
% (C) Stéphane Adjemian 2024
n = length(dir(sprintf('%s%shssmc%sparticles-*-*.mat', modelname, filesep, filesep)));
function densities = plot_all_distributions(modelname, nparticles, idparam)
% (C) Stéphane Adjemian, 2024
particles = load_all_distributions(modelname, nparticles, idparam);
[N,n] = size(particles);
densities = cell(n,2);
for i=1:n
bandwidth = mh_optimal_bandwidth(particles(:,i), N, 0, 'gaussian');
[x, f] = kernel_density_estimate(particles(:,i), 512, N, bandwidth, 'gaussian');
densities{i,1} = x;
densities{i,2} = f;
end
plot3(densities{1,1}, ones(512,1), densities{1,2}, '-k')
hold on
for i=2:25, plot3(densities{i,1}, i*ones(512,1), densities{i,2}, '-k'), end
axis tight
grid on
hold off
end
......@@ -89,3 +89,6 @@ estimation(order=1, datafile='fsdat_simul.m', nobs=192, loglinear,
'particles', 20000,
'scale',.5,
'target', .25));
addpath('../matlab');
plot_all_distributions('fs2000', 20000, 7); // autoregressive parameter (rho)
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