RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

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.

Re: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby jpfeifer » Wed Jul 07, 2010 12:34 pm

1. For some models the starting values do not matter as Dynare is able to find the steady state values easily by starting from anywhere in the parameter space. In particular, for linear models there is only one unique steady state. As the nonlinearity increases, giving exact starting values becomes more important.
2. Choosing a good prior distribution is an art. Ideally you want to let the data speak as freely as possible by choosing a non-informative prior. However, often the data (likelihood) does not contain much information about a parameter. In this case, choosing an informative prior is an important advantage of Bayesian methods that allows nevertheless estimating the model by incorporating prior information. There are attempts to give guidelines about choosing parameters http://www.econ.upenn.edu/~schorf/papers/dummyprior.pdf, but in general it is hard to give definite advice. Most importantly, the posterior assigns 0 likelihood to parameters regions that are not in the support of the prior. So one should be careful in restricting the prior space unless there is good reason too. If you do not know the range of a parameter, choose a wide prior. In contrast, if you know that alpha always is between 0.25 and 0.4 there is no reason to use a wider prior.
3. Sensitivity analysis would proceed in the way you describe. However, I would recommend using the syntax of the estimated_params block to specify starting values, e.g.:
Code: Select all
gamma,initial value, , ,inv_gamma_pdf,2.9,0.3;

Regarding the estimation-command, you cannot set the mh_replic=10000 as this is the number of MCMC draws which is currently rather small if you want to have a sensible burn-in (Dynare drops 50% by default). Rather, you don't want to have 5 separate chains starting at the same values to test if they converge to the same posterior mode as you want to have several chains from different starting values.
4. Your statement is wrong. Having the posterior diverge from the prior means that your data (the likelihood in Bayes rule) is very informative about the parameter (if the posterior distribution is not too wide around the mode). If all your posterior estimates would coincide with the prior mean, there would be no reason for estimation as the data does not add any new insights. Things are only different, if you are trying to replicate a study and your prior mean is already the posterior of an estimated model (not a calibrated one!). Then having different results may signal trouble.

NB: You may want to have a look at http://lehre.wiwi.hu-berlin.de/Professuren/vwl/wipo/team/former/kriwoluzky/intro_dynare_handout.pdf
------------
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: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby Bouba » Wed Jul 07, 2010 3:43 pm

Thank you once more for your very detailed and clear response. Just to clarify one of the point you made in part 4 of your answer " Things are only different, if you are trying to replicate a study and your prior mean is already the posterior of an estimated model (not a calibrated one!)" . In my case, since I am using a model which was calibrated using micro founded evidence about the deep parameters, my prior means are the relevant micro values used to calibrate the model. Thus, I understand by your explanation that for example although the value for gamma was 2 when the model was calibrated, the posterior mean I obtained being 9 is not an issue i.e. if this was indeed an issue what advice would you give me?. In the event of the later, not being a problem, is it right then to say that the model should be re-estimated using a value of gamma equal to 9?
I suspected that choosing the right bounds for the parameters was more of an art, hence this clearly is something I would need to double check with you since my understanding of all the present is only very recent. So do you think that my choice for bounds are ok in general:

stderr e,inv_gamma_pdf, 0.95,inf;
gamma,inv_gamma_pdf,2.9,0.3;
beta, beta_pdf, 0.97, 0.1;
alpha, beta_pdf, 0.31, 0.02;
rho, beta_pdf, 0.7, 0.02;
omega, inv_gamma_pdf, 2.5, 0.05;
sigma, normal_pdf, 0.3, 0.005;

And finally, two things is doubling the mh_replic to 20000 a better option?

Thank you so much for all your help.



Regards,
Bouba
Bouba
 
Posts: 22
Joined: Thu Jul 01, 2010 9:28 pm

Re: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby jpfeifer » Thu Jul 08, 2010 9:20 am

It is well known that micro-estimates of parameters may differ from parameter estimates in DSGE models. The best-known example is the Frisch elasticity of labor supply. The problem is that we often do not know how the microeconomic behavior translates to the aggregate. Hence, it is often difficult to take micro-evidence literally. Often they serve as a good starting point for the estimation, because these studies are prior knowledge. Getting a different posterior is not necessarily a bad sign as the data tells you it is more likely that the parameter has a different value, i.e. 9 instead of 2. This new information is the reason why you try to estimate the parameter in the first place.
Note that the difference to micro-evidence can have different reasons, some good, some bad. It may simply be due to aggregation or it could be that your model is severely misspecified. Consider for example the Frisch elasticity: if the true data generating process is something like and RBC model with a search and matching framework and you estimate this parameter using a monopolistic labor market with wage stickiness and indexing, the estimate may differ from the true value just because your model cannot capture the data generating process.

What do you mean with reestimate? Starting with Bayes rule and a prior of 2 for gamma, your new posterior is 9. If you estimate the model on a different data, you could reasonably argue that your new prior should be this posterior of 9. But if you are only comparing different models on the same data, you should use the prior of 2 and do model comparison.

Regarding the priors, it seems to me that most of the parameters may be standard in the literature. So orient yourself in these studies, e.g. with Schmitt-Grohe/Uribe (2010) with GHH preferences and investment specific technology http://www.columbia.edu/~mu2166/news_in_bc/paper.pdf, Fernandez-Villaverde (2010) for alpha and beta http://www.econ.upenn.edu/~jesusfv/econometricsDSGE.pdf and the classical work of An/Schorfheide http://www.econ.upenn.edu/~schorf/papers/er-final.pdf

Regarding mh_replic, the Dynare standard is 20000. In general, it is impossible to say a priori if this is sufficient or not. You have to make sure that your MCMC has converged to the posterior distribution. If this is already the case after 10000 iterations then this suffices. However, convergence could also only happen after 50000 draws or even more. You have to check this, e.g. using trace plots or convergence diagnostics. I personally would feel more comfortable with at least 20000 draws, which means a burn-in phase of 10000.
------------
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: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby Bouba » Thu Jul 08, 2010 10:42 am

Well, I feel as every single question I had on Bayesian estimation has been clearly and fully answered by you. All what is left to do now, I believe is to hit the books for more details. I am forever grateful for the unique support and help you have provided me with.

Thank you ever so much, God Bless you.

Regards,
Bouba
Bouba
 
Posts: 22
Joined: Thu Jul 01, 2010 9:28 pm

Re: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby Bouba » Wed Jul 14, 2010 2:14 pm

Hi jpfeifer ,

I have run into a strange problem and I was wondering if you could please help.
I just solved the GHH (1988) paper using quadratic approximation in Matlab. By running the file titled mainfile.m in Matlab (NB: make sure that hessp.m, gradp.m and utilfun.m are all in the same folder) I could get the same set of stdv, autocorrelation and other statistics presented in the paper. Note, that some of my steady states values here are :
k=0.567966;
l=0.3610;
h=0.251526;
c=0.2196;

Since my aim is to replicate GHH using Bayesian estimation, I though that a good place to start would be to first solve the model in Dynare, I therefore wrote the attached .mod file. And then, the following problem occurred: Although the file can run and gives me the statistics I need, the calculated steady states are completely different and thus the autocorrelation and other vital statistics between variables are also different. I actually get:
STEADY-STATE RESULTS:

y -0.64755
c -0.875989
k 0.0744721
h -1.38021
l -0.378713
i -2.23608
z 0

I tried using directly the values above as initial value in dynare but this gives me the following error message;

SOLVE: maxit has been reached
??? Error using ==> steady_ at 132
STEADY: convergence problems

Error in ==> steady at 52
steady_;

Error in ==> GHH at 120
steady;

Error in ==> dynare at 132
evalin('base',fname) ;


But as I said, if you use the equations the file runs but the statistics are not correct. Thank you again.

Regards,
Bouba
Attachments
GHH.mod
Dynare file to solve model
(1.81 KiB) Downloaded 191 times
hessp.m
Quadratic
(1.47 KiB) Downloaded 402 times
gradp.m
Quadratic
(983 Bytes) Downloaded 142 times
utilfun.m
Quadratic
(485 Bytes) Downloaded 133 times
mainfile.m
Quadratic
(7.05 KiB) Downloaded 155 times
Bouba
 
Posts: 22
Joined: Thu Jul 01, 2010 9:28 pm

Re: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby jpfeifer » Wed Jul 14, 2010 8:45 pm

Have you considered that the Dynare model is in logs?
------------
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: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby Bouba » Wed Jul 14, 2010 10:20 pm

Yes, I considered this, taking the log of the true steady state values:
k=0.567966;
l=0.3610;
h=0.251526;
c=0.2196;

did not give me the computed steady state value in Dynare, which are:
k= 0.0744721
h= -1.38021
l= -0.378713
c= -0.875989

What does the fact that Dynare solves the model in log implies for the general results (statistics of autocorrelation and so on)? I thought that I would have still obtained the same sort of final results as I did using quadratic approximation. Many thanks.

Regards,
Bouba
Bouba
 
Posts: 22
Joined: Thu Jul 01, 2010 9:28 pm

Re: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby jpfeifer » Thu Jul 15, 2010 5:12 am

Regarding the steady state, for the same parametrization (!), it should be identical between the quadratic approximation and Dynare. You cannot compare a calibrated version with estimation results where the parameters are different as the steady state depends on the parameters. If the parameters are the same and the steady state differs after accounting for having the model in logs, the models are apparently not identical and something is still wrong.
When you are trying to compare moments, you have to remember that a quadratic approximation means that certainty equivalence holds. Hence, you are doing a first-order approximation. So you should compare it to stoch_simul(order=1) and not Dynares default second order approximation. In the latter, uncertainty (the size of the shocks) influences the results.
As a last point, if you are trying the compare moments, you have to make sure that you compare the same thing. In Dynare there are both simulated and theoretical moments. I don't know what you do in the quadratic approximation case.
------------
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: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby Bouba » Thu Jul 15, 2010 11:59 am

Yes, you dead right about quadratic approximation and what the certainty equivalence implies for the estimation of the "calibrated" model. To explain what I did with quadratic approximation -I used the same set of values for the deep parameters as I did solving the model in dynare, then I simulated the model to generate the relevant moments. Hence, I guess in dynare I should be concerned with the simulated moments not the theoretical one. Again my estimation in dynare was done using the option (order=1) as you rightly pointed out. As you said, the current discrepancies may be down to something else being wrong, but for the moment I genuinely cannot see what this can be. I will keep on trying though. Many thanks.

Regards,
Bouba
Bouba
 
Posts: 22
Joined: Thu Jul 01, 2010 9:28 pm

Re: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby Bouba » Tue Jul 20, 2010 11:05 am

Dear jpfeifer,

I was wondering if you could help, I was running my sensitivity analysis when I got the following error:

java.lang.OutOfMemoryError: Java heap space
at java.lang.ClassLoader.findLoadedClass0(Native Method)
at java.lang.ClassLoader.findLoadedClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at com.mathworks.jmi.OpaqueJavaInterface.getExceptionMessage(OpaqueJavaInterface.java:1305)
??? Error using ==> drawnow
Failed to retrieve Exception Message


Error in ==> waitbar at 256
drawnow;

Error in ==> random_walk_metropolis_hastings_core at 121

waitbar(prtfrc,hh,[ '(' int2str(b) '/' int2str(options_.mh_nblck) ') ' sprintf('%f done,
acceptation rate %f',prtfrc,isux/j)]);

Error in ==> random_walk_metropolis_hastings at 73
fout = random_walk_metropolis_hastings_core(localVars, fblck, nblck, 0);

Error in ==> dynare_estimation_1 at 1061
feval(options_.posterior_sampling_method,'DsgeLikelihood',options_.proposal_distribution,xparam1,invhess,bounds,gend,data,...

Error in ==> dynare_estimation at 62
dynare_estimation_1(var_list,varargin{:});

Error in ==> ghhother1alpha5 at 159
dynare_estimation(var_list_);

Error in ==> dynare at 132
evalin('base',fname) ;

Error in ==> mainsensitivity at 9
dynare ghhother1alpha5.mod

Also, I cannot longer go to matlab and copy the following tables to paste in excel as the screen does no longer display all the results since there are so many of them i.e.
parameters
prior mean post. mean conf. interval prior pstdev

gamma 2.900 4.0351 3.1988 4.8358 invg 0.3000
beta 0.960 0.9889 0.9830 0.9952 invg 0.1000
alpha 0.200 0.2058 0.1745 0.2386 beta 0.0200
theta 0.600 0.5967 0.5640 0.6286 beta 0.0200
omega 2.500 2.5834 2.3560 2.8118 invg 0.0500
sigma 0.040 0.0404 0.0065 0.0724 norm 0.0200
rho 0.700 0.6893 0.6550 0.7219 beta 0.0200

standard deviation of shocks
prior mean post. mean conf. interval prior pstdev

e 0.950 0.2420 0.1639 0.3131 invg Inf

I know that in the output folder I can get the graphs for the priors and posteriors mean but this does not convey all the information. Would you know a way around this issue please, a code perhaps which will directly add the above table to the output folder? Many thanks.

NB: still no luck on getting the same steady state values solving the model in dynare vs quadratic approximation. I have consulted many people, but no one seem to know what is going on. I will keep on trying though.

Regards,
Bouba
Bouba
 
Posts: 22
Joined: Thu Jul 01, 2010 9:28 pm

Re: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby Bouba » Tue Jul 20, 2010 1:27 pm

I am using Matlab 7.8.0 (R2009a) on a 64 bits computer.

Thank you.
Bouba
 
Posts: 22
Joined: Thu Jul 01, 2010 9:28 pm

Re: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby jpfeifer » Tue Jul 20, 2010 4:49 pm

Regarding the problem with the java heap space, a workaround can be found at http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=2479.
For the parameters, everything you need is stored in the oo_ - structure as documented in the manual. You just have to write you own code to read out the information after Dynare has finished running.
------------
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: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby Bouba » Tue Jul 20, 2010 5:52 pm

Thank you.

Regards,
Bouba
Bouba
 
Posts: 22
Joined: Thu Jul 01, 2010 9:28 pm

Re: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby Bouba » Wed Jul 21, 2010 3:11 pm

Dear jpfeifer, I just got the following output from my bayesian estimation and was wondering if you knew what the red line on beta meant? as well as the discontinuity green line for omega. I know that a flat log likelihood kernel means that the data has no information, but in the case of rho the line is not flat in the sense of being parallel to the x axis, would you know the meaning of this.
In fact, what I wanted to plot initially was the negative of the log-likelihood as they did for the Ryoo and Rosen's model in Practicing Dynare, can you tell me what other information would give me as supposed to the one I plotted or are all these plots doing the same thing? Thank you so much.

Regards,
Bouba
Attachments
Check plots.pdf
(6.37 KiB) Downloaded 199 times
Bouba
 
Posts: 22
Joined: Thu Jul 01, 2010 9:28 pm

Re: RegardingERROR: GHH.mod:59.1: syntax error, unexpected NAME

Postby Bouba » Fri Jul 23, 2010 2:09 pm

Dear Mr Juillard,

I was wondering if you could please help with the following error I receive when I try to compare 2 models in dynare;
PosteriorIRF :: is not a declared endogenous variable!
??? Attempted to access IndxVariables(1); index out of bounds because numel(IndxVariables)=0.

Error in ==> PosteriorIRF at 187
if max(y(IndxVariables(j),:)) - min(y(IndxVariables(j),:)) > 1e-12

Error in ==> dynare_estimation_1 at 1078
PosteriorIRF('posterior');

Error in ==> dynare_estimation at 62
dynare_estimation_1(var_list,varargin{:});

Error in ==> ghhother1 at 162
dynare_estimation(var_list_);

Error in ==> dynare at 132
evalin('base',fname) ;


I went through your post with Tanya dating from 2006 and used the comparison option in the mod file as you advised her to, please see attached mod files (the option is in ghhother1.mod, after estimation). Since the models I am comparing have respectively 1 and 2 shocks I also used one observable for the first model and two for the second, hence the two data files.

Another problem I also encountered during my sensitivity analysis is that Dynare crashes when I use a small values for beta, I read in one of the post that this was a bug, has this been fixed now? .

My last question is a strange one but I just need to confirm this, why the name jumping distribution when we deal with the MH algorithm? is it because we are dealing with
a binomial probability distribution of the candidate parameter prior to each iteration? Thank you ever so much. And I must say that I really appreciate all the help you have given me so far.

Regards,
Bouba
Attachments
data2.m
(1.73 KiB) Downloaded 170 times
data.m
(916 Bytes) Downloaded 154 times
GHHother2.mod
(2.24 KiB) Downloaded 190 times
GHHother1.mod
(2.22 KiB) Downloaded 172 times
Bouba
 
Posts: 22
Joined: Thu Jul 01, 2010 9:28 pm

PreviousNext

Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 4 guests