Distribution of steady states after Metropolis iterations

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Distribution of steady states after Metropolis iterations

Postby Vik » Mon Feb 13, 2012 7:31 am

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
Vik
 
Posts: 14
Joined: Wed Jun 30, 2010 1:43 pm

Re: Distribution of steady states after Metropolis iteration

Postby jpfeifer » Mon Feb 13, 2012 7:05 pm

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
Code: Select all
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
Code: Select all
[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
Code: Select all
[T,R,SteadyState,info] = dynare_resolve('restrict');

in DsgeLikelihood.m you need to add
Code: Select all
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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Distribution of steady states after Metropolis iteration

Postby Vik » Tue Feb 14, 2012 11:01 am

Thanks a lot for helpful instruction. But, I can't find oo_.Metropolis_steady_state after running Metropolis iterations.
Vik
 
Posts: 14
Joined: Wed Jun 30, 2010 1:43 pm

Re: Distribution of steady states after Metropolis iteration

Postby jpfeifer » Tue Feb 14, 2012 1:12 pm

Could you post the mod-file? In the workspace, the structure oo_ should have a corresponding field called Metropolis_steady_state
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Distribution of steady states after Metropolis iteration

Postby Vik » Wed Feb 15, 2012 8:47 am

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.
Attachments
simuldataRBC.m
data
(141.14 KiB) Downloaded 51 times
RBC_Est.mod
estimation
(797 Bytes) Downloaded 54 times
Vik
 
Posts: 14
Joined: Wed Jun 30, 2010 1:43 pm

Re: Distribution of steady states after Metropolis iteration

Postby jpfeifer » Wed Feb 15, 2012 10:39 am

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
Attachments
DsgeLikelihood.m
(10.37 KiB) Downloaded 51 times
random_walk_metropolis_hastings_core.m
(11.83 KiB) Downloaded 60 times
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Distribution of steady states after Metropolis iteration

Postby Vik » Wed Feb 15, 2012 2:56 pm

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: :
    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]
Vik
 
Posts: 14
Joined: Wed Jun 30, 2010 1:43 pm

Re: Distribution of steady states after Metropolis iteration

Postby Vik » Wed Feb 15, 2012 6:39 pm

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?
    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]
Vik
 
Posts: 14
Joined: Wed Jun 30, 2010 1:43 pm

Re: Distribution of steady states after Metropolis iteration

Postby jpfeifer » Wed Feb 15, 2012 8:35 pm

Try using the Matlab "which" command to find out if the newer Matlab version actually calls the changed files, i.e. type
Code: Select all
which random_walk_metropolis_hastings_core.m

or alternativey
Code: Select all
edit random_walk_metropolis_hastings_core.m

to directly look into the file that is called.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Distribution of steady states after Metropolis iteration

Postby Vik » Thu Feb 16, 2012 7:26 am

Yes, that was the problem.
Thank you very much for help!
Vik
 
Posts: 14
Joined: Wed Jun 30, 2010 1:43 pm


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 11 guests