# Random starting points for mode-finding

**URL:** <https://forum.dynare.org/t/random-starting-points-for-mode-finding/27718>\
**Category:** ML/Bayesian estimation\
**Created:** [13 June 2025 17:17 UTC](https://forum.dynare.org/t/random-starting-points-for-mode-finding/27718 "2025-06-13T17:17:25Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [19 June 2025 08:41 UTC](https://forum.dynare.org/t/random-starting-points-for-mode-finding/27718/10 "2025-06-19T08:41:24Z")

</div>

The respective code in Dynare should be

```auto
[~, estim_params_, bayestopt_, lb, ub, M_]=set_prior(estim_params_, M_, options_);
prior_draw(bayestopt_,0);
N=10;
for par_iter=1:N
    xparam1=prior_draw;
    M_ = set_all_parameters(xparam1,estim_params_,M_);
    %delete previous initial values
    options_.use_calibration_initialization=true;
    estim_params_.var_exo(:,2)=NaN;
    estim_params_.var_endo(:,2)=NaN;
    estim_params_.corrx(:,2)=NaN;
    estim_params_.corrn(:,2)=NaN;
    estim_params_.param_vals(:,2)=NaN;
    estimation(nograph,order=1,datafile='Slovenia.m', mode_compute=5, mh_replic=0, nodiagnostic,plot_priors=0,cova_compute=0,first_obs=12,presample=4,lik_init=2,prior_trunc=0,silent_optimizer);
    fprintf('Iteration %u done.\n',par_iter)
    temp=load([M_.dname filesep 'Output' filesep M_.fname '_mode.mat'],'xparam1','fval')
    mode.posterior(par_iter,1)=temp.fval;
    mode.parameter(:,par_iter)=temp.xparam1;
end
save mode_parameter_results mode oo_ M_;

```

---

_[View the full topic](https://forum.dynare.org/t/random-starting-points-for-mode-finding/27718)._
