Hi!

I need the distribution of steady states after Metropolis iterations. Is it possible to see (or find, or save somehow) the distribution of steady states?

Thank you

Hi!

I need the distribution of steady states after Metropolis iterations. Is it possible to see (or find, or save somehow) the distribution of steady states?

Thank you

This one is tricky. You need to change two files in Dynare 4.2.4. First, in matlab\random_walk_metropolis_hastings_core.m you need to insert

`oo_.Metropolis_steady_state=NaN(size(oo_.steady_state,1),nblck*nruns(1));`

after line 133 (jloop=0;).

Moreover, in DsgeLikelihood.m, you need to insert

```
[ST,I] = dbstack;
if strcmp(ST(2).name,'random_walk_metropolis_hastings_core')
j=evalin('caller','j');
b=evalin('caller','b');
nruns=evalin('caller','nruns(1)');
oo_.Metropolis_steady_state(:,(b-1)*nruns+j)=zeros(size(oo_.steady_state));
end
```

after line 46 (nobs = size(options_.varobs,1);). Finally, after the line

```
[T,R,SteadyState,info] = dynare_resolve('restrict');
```

in DsgeLikelihood.m you need to add

```
if strcmp(ST(2).name,'random_walk_metropolis_hastings_core')
oo_.Metropolis_steady_state(:,(b-1)*nruns+j)=SteadyState;
end
```

After running the MCMC the steady states are saved in oo_.Metropolis_steady_state. Steady states from different chains are stacked in column order. Invalid parameter draws have a SS of NaN.

Thanks a lot for helpful instruction. But, I can’t find oo_.Metropolis_steady_state after running Metropolis iterations.

Could you post the mod-file? In the workspace, the structure oo_ should have a corresponding field called Metropolis_steady_state

I find oo_.Metropolis_steady_state if I run the cods in Matlab 7.0.0 version, although steady states from different chains are stacked in one row. But I can’t find it in Matlab 7.12.0.635 (R2011a) version. Attached is just slightly changed RBC_est.mod file from User guide example.

simuldataRBC.m (141 KB)

RBC_Est.mod (797 Bytes)

Using Matlab 2011b, it works on my machine. I get a 9*4000 matrix that contains the 2000 steady states vectors of size 9 by 1 for the two chains. Attached are the modified file from Dynare 4.2.4

DsgeLikelihood.m (10.4 KB)

random_walk_metropolis_hastings_core.m (11.8 KB)

I suggest it’s a problem with my Matlab. After running the program with the modified files from Dynare 4.2.4, I get the following fields of oo-. structure, and still can’t find Metropolis_steady_state field: : [ul]oo_ =

```
exo_simul: 0
endo_simul: [9x1 double]
dr: [1x1 struct]
exo_steady_state: 0
exo_det_steady_state: ]
exo_det_simul: ]
steady_state: [9x1 double]
posterior_mode: [1x1 struct]
posterior_std: [1x1 struct]
MarginalDensity: [1x1 struct]
posterior_mean: [1x1 struct]
posterior_hpdinf: [1x1 struct]
posterior_hpdsup: [1x1 struct]
posterior_median: [1x1 struct]
posterior_variance: [1x1 struct]
posterior_deciles: [1x1 struct]
posterior_density: [1x1 struct]
prior_density: [1x1 struct]
Smoother: [1x1 struct]
FilteredVariablesKStepAhead: [0x9x101 double]
SmoothedVariables: [1x1 struct]
FilteredVariables: [1x1 struct]
UpdatedVariables: [1x1 struct]
SmoothedShocks: [1x1 struct][/ul]
```

For Matlab 7.0.0 it seems to be OK. Should I deinstall all previous Dynare versions or remove the Matlab path to them to get the result?

[ul]oo_ =

```
exo_simul: 0
endo_simul: [9x1 double]
dr: [1x1 struct]
exo_steady_state: 0
exo_det_steady_state: ]
exo_det_simul: ]
steady_state: [9x1 double]
posterior_mode: [1x1 struct]
posterior_std: [1x1 struct]
MarginalDensity: [1x1 struct]
Metropolis_steady_state: [9x4000 double]
posterior_mean: [1x1 struct]
posterior_hpdinf: [1x1 struct]
posterior_hpdsup: [1x1 struct]
posterior_median: [1x1 struct]
posterior_variance: [1x1 struct]
posterior_deciles: [1x1 struct]
posterior_density: [1x1 struct]
prior_density: [1x1 struct]
Smoother: [1x1 struct]
SmoothedVariables: [1x1 struct]
FilteredVariables: [1x1 struct]
UpdatedVariables: [1x1 struct]
SmoothedShocks: [1x1 struct][/ul]
```

Try using the Matlab “which” command to find out if the newer Matlab version actually calls the changed files, i.e. type

or alternativey

to directly look into the file that is called.

Yes, that was the problem.

Thank you very much for help!