Construct likelihood given parameter vector

I’m wondering if it is possible to run a mod file once and then feed in parameter vectors and retrieve the likelihood using the dsge_likelihood function. A previous post I found asking a similar question is: The main difference between what I would like to do and what is recommended here is that I would like to use the dsge_likelihood function outside of the mod file. I’ve tried this but receive a few errors which I think are related to the local nature of some of the variables.

If the above cannot be done, is my best approach to use the state space setup of the model produced by Dynare and run it through my own Kalman filter codes? Perhaps making use of the resol function for each parameter draw?

I’m ultimately interested in coding some of my own mcmc sampling routines for estimation. But for some of the models I am using, writing the state space of the model takes a significant amount of time. I’m hoping I can use Dynare to produce the state space (or even evaluate the likelihood) and then simply add it into my routines. Any suggestions are appreciated.


Would you be interested in doing it in DynareJulia?

Can you provide your codes to see the error messages?

Codes are attached. Currently just trying with the version of Smets Wouters posted on your Github. The error I get is:

Reference to non-existent field ‘analytic_derivation’.

Error in dsge_likelihood (line 143)
if DynareOptions.analytic_derivation

Error in Main (line 6)
[likelihood,junk1,junk2,exit_flag,ys,trend_coeff,info] = dsge_likelihood(xparam1,dataset_,options_,M_,estim_params_,bayestopt_,oo_);

Perhaps this is an issue of trying to pass a structure through the function? In my Matlab workspace, options_.analytic_derivation does exist as an input. (26.5 KB)

If it can be done in DynareJulia, I would be open to doing it there.

Use Dynare 5 together with

dynare Smets_Wouters_2007_45.mod noclearall
%[dataset_,xparam1, hh, M_, options_, oo_, estim_params_,bayestopt_] = dynare_estimation_init(var_list_, M_.fname, [], M_, options_, oo_, estim_params_, bayestopt_);
[dataset_, dataset_info, ~, ~, M_, options_, oo_, estim_params_,bayestopt_, bounds] = dynare_estimation_init({}, M_.dname, 0, M_, options_, oo_, estim_params_, bayestopt_);
[fval,info,exit_flag] = dsge_likelihood(xparam1,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_,[]);

It can be done in Dynare Matlab or in DynareJulia. For Julia look at GitHub - DynareJulia/Dynare.jl: A Julia rewrite of Dynare: solving, simulating and estimating DSGE models.
The estimation code under development is in branch estimation_3