Page 2 of 4
Re: Likelihood only!
Posted:
Fri May 23, 2014 11:55 am
by Glm
I use this method for Smets and Wouters (2007) model and then I grid the parameters one at the time between wide intervals. The parameter value is on the x-axis and the likelihood is on the y-axis.
The interval for the shock parameters are 0.01-5. The strange thing however is that many of the shocks, technology for instance, is just a horisontal line as if it doesn't affect the likelihood at all. Does this make sense? What could this mean?
Re: Likelihood only!
Posted:
Fri May 23, 2014 2:19 pm
by jpfeifer
Please post or send the whole code. It might have to do with the covariance matrix not correctly updating.
Re: Likelihood only!
Posted:
Mon May 26, 2014 10:50 am
by Glm
The files are about 10 mb because of all the big arrays that I saved from Dynare. Therefore I sent the files here instead
http://sprend.com/download.htm?C=beff9a ... 09348fd8e1 under the name 'all_code.zip'
You open the m-file 'submit_code.m' and click run, then Matlab loads the matrices you need from the mat-file 'a_sw.mat'. Next, Matlab, grids all of the parameters one at the time around the parameter vector 'param_vec_fcon'. When this is done the function 'subplot_funktion' is used to plot all of the parameters with the likelihood on the y-axis, where the black vertikal line is the paramater value from the initial parameter vector 'param_vec_fcon'.
All the shocks are named sigma_x. So for instance the technology shock is called "sigma_a", these symbols you'll see in the subplots.
Let me know if you are missing any files
Re: Likelihood only!
Posted:
Mon May 26, 2014 11:33 am
by jpfeifer
numSubplots.m is missing.
Re: Likelihood only!
Posted:
Mon May 26, 2014 12:08 pm
by Glm
Sorry about that. Here it is
\\\Glenn
Re: Likelihood only!
Posted:
Mon May 26, 2014 12:53 pm
by jpfeifer
I may be missing something, but you are seem to be confusing the ordering in M_.params with the one used in estimation. E.g. you take parameter 20 in xparam1 to be the s_tech, but the actual ordering is in bayestopt_.name. There you can see that the first entry is the standard error of ea (which is s_tech). The parameters with the flat likelihood are actually the constants of the observation equation.
Re: Likelihood only!
Posted:
Wed May 28, 2014 2:28 pm
by Glm
Yes you're right. I didn't realize that the parameter order was different when estimating. Thank you very much!!
Re: Likelihood only!
Posted:
Thu Jul 03, 2014 8:16 am
by Glm
Let's say that I use this method and end up with some estimates of my parameters. Is there then some way to relatively easy make inference of these parameters in Dynare?
Re: Likelihood only!
Posted:
Thu Jul 03, 2014 10:01 am
by jpfeifer
Which type of inference do you mean? And how did you estimate your parameters. You can always work with Delta-methods yourself, but Dynare does not provide prepackage routines for inference on external estimates.
Re: Likelihood only!
Posted:
Thu Jul 03, 2014 2:41 pm
by Glm
With inference I mean being able to say how certain each one of the parameter values are. I estimated it by the use of an algorithm that changed the parameter vector with regard to the likelihood until it reach an optimum. Yeah I had something like the delta method in mind or maybe a MCMC.
Re: Likelihood only!
Posted:
Fri Jul 04, 2014 8:29 am
by jpfeifer
See for example Ruge-Murcia "Methods to Estimate Dynamic Stochastic General Equilibrium Models" on how to use the inverse hessian to get the asymptotic distribution of parameters from the likelihood function. Using numerical differentiation, you can easily compute this from the likelihood function. The relevant part from Dynare's code in the current snapshot is:
- Code: Select all
hh = reshape(hessian(dsge_likelihood,xparam1, ...
options_.gstep,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_),nx,nx);
invhess = inv(hh);
stdh = sqrt(diag(invhess));
oo_.posterior.optimization.Variance = invhess;
Re: Likelihood only!
Posted:
Fri Jul 04, 2014 11:00 am
by Glm
Oki, nice! Thanks for the advice
Re: Likelihood only!
Posted:
Fri Sep 05, 2014 11:27 am
by Glm
When estimating I've realised that every once in a while Matlab gives the following warnings
1. From the m-file evaluate_steady_state.m row 86: ys = ys_init-jacob\fvec.
Then it sometimes gives the warning message that the jacobian is badly scaled and the results may be inaccurate
2. In the m-file dyn_first_order_solver.m row 315: ghu = - A_ \ fu;
Then it sometimes gives the warning message that A_ is badly scaled and the results may be inaccurate
3. In the m-file lyapunov_symm2.m It's regarding the q matrix row 158 and row 185.
Then it sometimes gives the warning message that q is badly scaled and the results may be inaccurate
How to think about this problems? I've realised that in regions when this happens a lot the log likelihood function sometimes goes to a very high value. Which is unrealisticly high and sometimes even 0, which is the highest possible value that a log likelihood function can get.
Re: Likelihood only!
Posted:
Fri Sep 05, 2014 11:41 am
by jpfeifer
These are areas where the parameters result in numerical problems and results should be taken with a grain of salt as they may be numerically imprecise. That's why you get the warning. Inversion of a near-singular matrix is required in those steps.
Regarding your last statement: it's not true that 0 is the highest value of a log-likelihood as we are talking about pdfs of continuous distributions. See
http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=2847Also, when you say high likelihood values, are we talking about the actual likelihood or minus the likelihood. Because ideally those problems result in low likelihoods and the draws are rejected.
Re: Likelihood only!
Posted:
Fri Sep 05, 2014 12:09 pm
by Glm
Oki, you're right about the 0 thing.
I mean the log likelihood, so in absolute terms the lower value the better (more likely). But can't it be that these inaccuracy problems produces unrealistically good values and therefore tricks one to believe that this is the best likelihood value? I mean, is there a guarantee that the values are always wrong in the since that they produces a bad likelihood? Shouldn't the inaccuracy go both ways?