jmaih / RISE_toolbox

Solution and estimation of Markov Switching Rational Expectations / DSGE Models
BSD 3-Clause "New" or "Revised" License
105 stars 78 forks source link

A question on Bayesian estimation #68

Closed cjrodriguez453 closed 6 years ago

cjrodriguez453 commented 6 years ago

Hi Junior,

I'm trying to do a bayesian estimation in RISE, but facing some probelms. Hope that you can help me.

First, I create and solve the RISE object, using:

m = rise('model.rs','definitions_inserted',true);
m = solve(m,'solver','mfi','solve_order',1','data',mydata_ffrRate) ;

then, I initialize the bayesian estimation:

[objective,lb,ub,x0,SIG] = pull_objective(m);
%  SIG=utils.cov.nearest(SIG);
draws_mcmc    = 1000; 
ndraws_burnin = floor(0.40*draws_mcmc);
mcmc_options=struct('burnin',ndraws_burnin,'N',draws_mcmc,'thin',5);
Results=mh_sampler(objective,lb,ub,mcmc_options,x0,SIG);

Even though after "[objective,lb,ub,x0,SIG] = pull_objective(m)", I get X0, lb, ub and obj, the initial covariance matrix "SIG" is not correct. Actually, "SIG" is a mtrix full of NaN, and therefore the mh_sampler cannot initialize the mcmc.

Do you have any idea what I'm doing wrong? Thanks in advance

Regards,

Carlos

cjrodriguez453 commented 6 years ago

The result is the same, even if I initialize the mh_sampler after a standard estimation procedure is done (using the likelihood).

m=estimate(m,'kf_init_variance' ,10,'kf_presample',5,'kf_ergodic',true, 'optimizer','bee_gate','optimset',myoptim);

jmaih commented 6 years ago

Hi Carlos,

In the second case where you first estimate the model, either change the optimizer to something like fmincon OR do m=hessian(m) right after estimation.

In the first case, you have not computed any covariance matrix in any of the statements and unsurprisingly there is no covariance matrix to be expected. The theory, which does not always work well in practice, says that all one needs is a starting point x0 and a covariance matrix SIG. And so, if you don't have a covariance matrix you can always invent one, say the identity matrix. In that case though, you may want to trigger the option to update the covariance matrix as the simulation proceeds.

Cheers,

Junior

On Tue, Dec 19, 2017 at 3:26 AM, cjrodriguez453 notifications@github.com wrote:

The result is the same, even if I initialize the mh_sampler after a standard estimation procedure is done (using the likelihood).

m=estimate(m,'kf_init_variance' ,10,'kf_presample',5,'kf_ergodic',true, 'optimizer','bee_gate','optimset',myoptim);

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jmaih/RISE_toolbox/issues/68#issuecomment-352620584, or mute the thread https://github.com/notifications/unsubscribe-auth/ACagzyZwK1Kgx7149rN1geZlH4cxuMQCks5tBx7rgaJpZM4RGQgt .

cjrodriguez453 commented 6 years ago

Many thanks for the clarifications.

Regards, Carlos