#acl DynareWriterGroup:read,write,delete,revert DynareTeamGroup:read,write,delete,revert,admin All:read = How to obtain trace plots after a Metropolis-Hastings = It can be useful to plot iterations vs. sampled values for each variable (parameter) in a chain. If the Metropolis-Hastings converges to a stable distribution, the trace plot has to be stable (e.g. no trend in the sampled values). After a metropolis (that is after the '''estimation''' command in the mod file) you just have to write: {{{ trace_plot(options_,M_,estim_params_,type,blck,name1,name2) }}} where: * options_, M_ and estim_params_ are Dynare's global structures describing the model, * type is a string equal to '!DeepParameter' (for a parameter of the structural model), '!MeasurementError' (std. or correlation in the measurement equation error) or '!StructuralShock' (for the standard deviation of a structural shock or the correlation between two shocks), * blck> where <> is the number of simulations in the Metropolis Hastings chain, the moving average curve is defined as: {{{#!latex \[ a_{j}=\frac{1}{2q+1}\sum_{k=-q}^{q} \alpha_{j+k} \] }}} for all <> between <> and <>. The default value of <> is 200. The value of <> may be changed by writing: {{{ options_.trace_plot_ma = 2222; }}} before the call to trace_plot. A value of <> roughly equal to <> of <> seems to be reasonable. In our example, we see that the moving average curve is slightly downward slopping, meaning that the Metropolis Hastings did not reach the ergodic distribution after 22000 draws.