Problems about Bayesian and MCMC estimation

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.

Problems about Bayesian and MCMC estimation

Postby wyl » Sun Oct 09, 2016 4:12 pm

Hello everyone, I'm doing a topic which is related to Jaaskela and Jennings' work in 2011. For first part, basically I'm replicating the same model and methods with different country's data.
I need to say thanks to tophukg, a user here. He was doing the same topic and shared his work. I've amended his model, like some input mistakes, and estimation commands. Yet now, I meet the same problem as he did. I need to get posterior estimates and the true IR graph, but Dynare doesn't show anything after I run my model, even error message.
So I have some questions:

1) Does this problem result from my data file or input commands? Or my estimation commands?
2) If not, I doubt the problem be within parameter value block or obs_variable definition block, since the other model part is the same as the Journal, only country parameters differ. Especially obs_variable part, the data is quaterly, but I'm not sure if I should amend the definition for impulse response. I have tried many other ways but still it doesn't work out.

The article (only part 2 and 3 are related to the problem), mod file and data file are attached. Appreciate it if anybody can give me some advice.
Attachments
Jaaskela 2011.rar
Jaaskela(2011), data excel, and mod file
(540.24 KiB) Downloaded 93 times
wyl
 
Posts: 10
Joined: Thu Sep 08, 2016 7:49 pm

Re: Problems about Bayesian and MCMC estimation

Postby jpfeifer » Sun Oct 09, 2016 7:25 pm

You uploaded an invalid mod-file.
1.) It does not conform to Matlab's naming convention where files need to start with a letter
2.) You have defined parameters as model-local variables. You need to fix this.
------------
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: Problems about Bayesian and MCMC estimation

Postby wyl » Mon Oct 10, 2016 5:05 pm

Sorry jpfeifer, I have renamed it and uploaded a new one.
And thank you for advice about the model local variables. In Jaaskela's work, they used quaterly data, so I just try to stay in line with them and use same quaterly data but a different country. However for the obs variables part, because of the quarterly data, I am really not sure whether I should define obs_r = 4 * r, and obs_q (exchange rate) defined as q-q(-1) or just q. The code of this part in attachment is from the previous user's work, I prefer my own thought, but none of them works out.

At least I got error message now. The model part is the same as Jaaskela's work, so I think the problem must be in parameter or estimation part.
Attachments
dis1.zip
(558.63 KiB) Downloaded 69 times
wyl
 
Posts: 10
Joined: Thu Sep 08, 2016 7:49 pm

Re: Problems about Bayesian and MCMC estimation

Postby jpfeifer » Mon Oct 10, 2016 7:44 pm

Please read Pfeifer(2013): "A Guide to Specifying Observation Equations for the Estimation of DSGE Models" https://sites.google.com/site/pfeiferecon/Pfeifer_2013_Observation_Equations.pdf. The original paper uses linearly detrended data. That stationary data will directly correspond to the stationary model variables. Thus, do not define the observed variables as growth rates! The interest rate in your loglinearized model that should be the log of the gross quarterly interest rate, which is approximately the net quarterly interest rate. If your observed interest rate is annual, you need the factor 4.
------------
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: Problems about Bayesian and MCMC estimation

Postby wyl » Thu Oct 13, 2016 10:08 pm

Really thanks for your article, professor Pfeifer, that detrend and demean part is really helpful.

Some questions: in your article's demean part, the demeaned interest rate in my case, should be obs_r = log(1+r/(4*100)), but you said "the interest rate in your log-linearized model should be the log of gross quarterly interest rate". I am not sure I totally understand you words and whether I defined a right obs demeaned interest rate.

And also, when I run my mod, whatever I change obs variables or not, it always shows :
Error using dynare (line 19)
syntax error at line 68
Even I downloaded other users' data files and ran their mod, like the Stone_Geary_moments_bayes mod from user "lilia", the error message is almost the same:
Error using dynare (line 19)
syntax error at line 153
Is that possible that other than the codes, there is something which goes wrong with my dynare ? Because I checked the known bug file you shared, there is no such error.

Or inappropriate shocks or estimation commands result in this error?

Sorry if my questions are too beginner.
Attachments
dis3.zip
(558.63 KiB) Downloaded 72 times
wyl
 
Posts: 10
Joined: Thu Sep 08, 2016 7:49 pm

Re: Problems about Bayesian and MCMC estimation

Postby jpfeifer » Fri Oct 14, 2016 6:34 am

Again, you have defined parameters as model-local variables (e.g. SIGMAa). Please try the mod-files in the dynare examples folder to see whether everything works, in particular the fs2000.mod.
Regarding the interest rate, if r is your annual net interest rate in percentages as measured in your data, the corresponding quarterly gross interests is:
Code: Select all
1+r/(4*100)

So what you posted is exactly what I said.
------------
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: Problems about Bayesian and MCMC estimation

Postby wyl » Fri Oct 14, 2016 9:42 pm

Thanks a lot, I have fixed the parameters. And yes, I have tried the examples. For fs2000 and fs2000a, I can get estimates and figures, but I got error messages for example1 and example2 in example file.
*for example1, messagess are:

MODEL SUMMARY

Number of variables: 6
Number of stochastic shocks: 2
Number of state variables: 3
Number of jumpers: 3
Number of static variables: 1
Error using table (line 281)
Wrong number of arguments.

Error in stoch_simul (line 71)
table(my_title,headers,labels,Sigma_e_,lh,10,6);

Error in example1 (line 110)
info=stoch_simul(var_list_);

Error in dynare (line 26)
evalin('base',fname) ;

Caused by:
You may have intended to create a table with one row from one or more variables that are
character strings. Consider using cell arrays of strings rather than character arrays.
Alternatively, create a cell array with one row, and convert that to a table using CELL2TABLE.



*For example2, error messages are:

Error using dynare (line 19)
DYNARE: could not open example.mod

*And also I found some examples in the forum, in which those users said they are able to get results or figures. But I can't run the mod files they shared. for example when I ran the mod (I also attached it)from viewtopic.php?f=1&t=6371 , again I got the same error:

Error using dynare (line 19)
syntax error at line 261

*But that poster said he was able to get estimates. So maybe it arises from the dynare version? My dynare file name is dynare_v3.
Attachments
dis3.zip
(563.15 KiB) Downloaded 65 times
wyl
 
Posts: 10
Joined: Thu Sep 08, 2016 7:49 pm

Re: Problems about Bayesian and MCMC estimation

Postby jpfeifer » Sat Oct 15, 2016 11:17 am

Please make sure you use Dynare 4.4.3. When running a mod-file, Dynare tells you which version it is using, e.g.
Starting Dynare (version 2016-07-16).
Starting preprocessing of the model file ...

Also, are you using Matlab or Octave?
------------
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: Problems about Bayesian and MCMC estimation

Postby wyl » Mon Oct 17, 2016 1:29 pm

Thank you very much professor! Now I am using Matlab, and I checked some results but I didn't find the version information. I'm still quite sure it is not latest version though.
However, when I was trying to download the version 4.4.3, I found the school lab pc is blocked so I can't install it.
When we got in touch with dynare, our tutor just gave us a dynare file. I don't know whether it works if I copy a 4.4.3 file to pc directly.

If so, can anybody here share the 4.4.3 dynare file? Really appreciate any help !
Or if anybody gets different error messages when running my code (mod and data in dis3.zip), please tell me, so I can make it clear if it is a version problem or code problem. Thanks !
Attachments
dis3.zip
(558.63 KiB) Downloaded 59 times
Last edited by wyl on Mon Oct 17, 2016 4:19 pm, edited 2 times in total.
wyl
 
Posts: 10
Joined: Thu Sep 08, 2016 7:49 pm

Re: Problems about Bayesian and MCMC estimation

Postby jpfeifer » Mon Oct 17, 2016 2:12 pm

You can install Dynare 4.4.3 on a different computer and the just copy the folder to a different computer.

With your current mod-file the problem is that PHIa is not defined. It should most probably either be a model-local variable or a parameter.
------------
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: Problems about Bayesian and MCMC estimation

Postby wyl » Thu Oct 20, 2016 6:02 pm

Thanks a lot, professor. Now I can run the mode, but I meet some new error messages.
The aim is to get the reaction and the posterior estimates of the model from a monetary shock. To equal the equations and endogenous variables' number, I have to set the first 8 equations as model local variables.
And then it shows that there are some problems in initival value part. I have tried many different values but still it doesn't work.
Also I slightly changed the shocks part and shock distribution part, I don't know whether the change is right.
So is there any incorrect expressions within these parts which could lead the errors?
Attachments
dis4.zip
(557.21 KiB) Downloaded 59 times
wyl
 
Posts: 10
Joined: Thu Sep 08, 2016 7:49 pm

Re: Problems about Bayesian and MCMC estimation

Postby jpfeifer » Fri Oct 21, 2016 7:12 am

First make sure your model runs with stoch_simul, before moving to estimation. The reason your model does not run is that two of your observation equations are not mean 0. You need to add
Code: Select all
obs_r   = 1+r/(4*100);
obs_rs   = 1+rs/(4*100);

to the initval block (and ideally make it a steady_state_model-block, because you know the steady state of your model). Then check whether the model works. After that, work on getting the observation equation right. The original paper uses demeaned growth rates, but your data is still trending. x shows a big seasonal pattern that needs to be removed. The two observation equations above are also incorrect, because the data are net rates. Your r in the model would most probably be
Code: Select all
r=log(1+r_data/(4*100))
------------
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: Problems about Bayesian and MCMC estimation

Postby wyl » Fri Oct 21, 2016 10:41 pm

Thanks, I have made some changes based on your advice. The excel data has been adjusted, q, pis, xs, pi, x are log(q), log(pis), log(xs), log(pi), log(x), and r, rs are log(1+r/(4*100)) and r=log(1+rs/(4*100)) now.
I tried add the 2 observation equations to initval block too but it seems not work. So I tried keeping this part unchanged because now the these 2 are mean 0 (I am not sure), then I got some results from the model.
But still, something goes wrong, I can only get some weird prior values, not for all parameters. Also during estimation, there were 3 options, when I chose option 1 and 2, posterior estimation still doesn't work.
I tried different parameter values for estimation as well, but none works out.
Attachments
dis4 (2).zip
(569.63 KiB) Downloaded 59 times
wyl
 
Posts: 10
Joined: Thu Sep 08, 2016 7:49 pm

Re: Problems about Bayesian and MCMC estimation

Postby jpfeifer » Mon Oct 24, 2016 8:57 am

1. Your data still does not match the observation equations. The data is not mean 0, while your model variables are.
2. I guess you mean posterior estimates? That is caused by 1)
3. Whether you select all endogenous variables or only all observed variables does not matter for estimation, just for the display of results.
------------
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: Problems about Bayesian and MCMC estimation

Postby wyl » Tue Oct 25, 2016 12:11 am

Really thanks for your help and patience, professor, but I think I still don't get the point.
As the guide says, to get data detrended and demeaned, observation equations for pi, pis, x, xs, q should be log(pi), log(pis)..log(q), and for r and rs, obs_r and obs_rs should be log(1+r/(4*100) and log(1+rs/(4*100)).

Also another way, when I see some people here do some preliminary data work, I tried to fix the data manually, because the data is not mean 0.
I have tried many different ways for matching observation equations and data, they still don't match. So it's little bit confusing that whatever I tried, the data is still not mean 0.
wyl
 
Posts: 10
Joined: Thu Sep 08, 2016 7:49 pm

Next

Return to Dynare help

Who is online

Users browsing this forum: No registered users and 10 guests