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:

After the estimation of the model in fs2000.mod if we want to build a trace plot for parameter alp, we just have to write:

trace_plot(options_,M_,estim_params_,'DeepParameter',2,'alp')

and the following plot will pop up:

attachment:trace_plot.jpg

where the black curve is a moving average of the sampled values. That is, if the sampled values are latex($\'\alpha_i\}_{i=1}^N$) where latex($N$) is the number of simulations in the Metropolis Hastings chain, the moving average curve is defined as:

\[
a_{j}=\frac{1}{2q+1}\sum_{k=-q}^{q} \alpha_{j+k}
\]

for all latex($j$) between latex($q+1$) and latex($N-q$).