Okay. This is possibly offtopic and you may want to transfer it into a new topic, however: after the RW-MH, I want to conduct the following operation:
“First, we try to estimate the DSGE model using a classical maximum likelihood approach to inference. Technically this is done by a Kalman filter approach. To run the Kalman filter procedure, initial values for the parameters of interest must be specified, however. Because likelihoods can have several peaks, we use multiple starting values. We do this to make sure that we indeed estimate the parameters that maximize the likelihood (or, in our case, minimize the negative log-likelihood, which is equivalent). To implement this, we set up a loop that performs 2,500 different draws of vectors of starting values. This indeed takes some time (several hours). Of course, you can reduce the number of draws and therefore the computational time. All this is done by running the script “run.m” placed in the folder “Searching for Starting Values - Full Sample”.”
I run this using the file in attachment:
run.m (6.6 KB)
The file runs for several hours, during which I obtain 796 repetitions of the following output:
I’ve obtained assurances that the file runs correctly, however, can you confirm me that the output is correct for my needs? Thanks in advance!
That is hard to tell. The general structure looks correct, but you did not provide all files necessary to execute the code. The warning message you post are usually not a reason to worry.
First, can you tell me how to upload .DAT file? The forum reports an error saying that it supports only certain types of files.
Second, please apologize my beginner knowledge, however how can I open .DAT file with Octave. I only know how to load .M files and run .MOD files. I can open it with Notepad, however it contains no name of columns and no row quarterly time data.
Thanks in advance again!
Try uploading everything as a zip file.
Are these two files sufficient?
run.zip (4.8 KB)
There is no llfn
function. That being said, you are posting someone else’s replication files. Where is your attempt at doing this? From what I can see, you basically need to update the initial values in estim_params_.param_vals
and then call dynare_estimation.m
.
I added the llfn function:
llfn.zip (2.8 KB)
Mr Röhe was kind enough to forward me his code for running parameter stability test. I hope I’m not disclosing anything too personal here? My master thesis is basically replication of Mr Röhe’s PHD thesis. He tested the parameter stability for Germany, France and Spain, and I’m doing the same for Slovenia, Austria and Italy.
Finally, I found no files with names estim_params_.param_vals and dynare_estimation.m or references to them in file run.m. Please, could you tell me where are they located?
My last post pointed to how to implement the same exercise in Dynare. The llfn.m
would require you to manually linearize the model and run ML outside of Dynare.
Thank you for your reply! Perfect, I would very much like to run the test in Dynare. But I didn’t found that two files on my computer, neither I find anything on Google. Is there a chance that you give me a hint where are they?
The respective code in Dynare should be
[~, estim_params_, bayestopt_, lb, ub, M_]=set_prior(estim_params_, M_, options_);
prior_draw(bayestopt_,0);
N=2;
for par_iter=1:N
xparam1=prior_draw;
M_ = set_all_parameters(xparam1,estim_params_,M_);
estimation(nograph,order=1,datafile=fs2000_data, loglinear,logdata, mode_compute=5, mh_replic=0, nodiagnostic,plot_priors=0,cova_compute=0);
temp=load([M_.dname filesep 'Output' filesep M_.fname '_mode.mat'],'xparam1')
mode_parameter(:,par_iter)=temp.xparam1;
end
fs2000.mod (6.1 KB)
1 Like
Many thanks for the code! If I understand it correctly, with file fs2000 I do both updating the initial values in estim_params_.param_vals and then calling dynare_estimation.m.
After this, I can run the parameter stability test run.m that I uploaded earlier in zip-folder. Do I understand this correctly? Thanks again!
This is the output of running fs2000:
Yes, you that is correct. The datafile necessary is in the Dynare examples
folder.
One question, I think I missunderstood you. I should just add the following part of file fs2000 (to my file Model6), that you quoted:
[~, estim_params_, bayestopt_, lb, ub, M_]=set_prior(estim_params_, M_, options_);
prior_draw(bayestopt_,0);
N=2;
for par_iter=1:N
xparam1=prior_draw;
M_ = set_all_parameters(xparam1,estim_params_,M_);
estimation(nograph,order=1,datafile=fs2000_data, loglinear,logdata, mode_compute=5, mh_replic=0, nodiagnostic,plot_priors=0,cova_compute=0);
temp=load([M_.dname filesep 'Output' filesep M_.fname '_mode.mat'],'xparam1')
mode_parameter(:,par_iter)=temp.xparam1;
end
I’m not supposed to run entire fs2000 file that obviously includes different variables and parameters than my model?
Yes, of course you still need to port that code snippet to your own application.
Okay, another question. Do I need to adjust also command “datafile=fs2000_data”? My input data for file Model7 is the file data1.MAT, which I cannot open with Octave, I obtain the following error if I try opening it with Octave:
Model7.mod (4.5 KB)
data1.mat (4.9 KB)
You are supposed to load the binary file in Octave, not try to open it as a text file in the Octave editor.
I understand. But your .MOD file fs2000.MOD is referring to the data file fs2000_data, which I can’t find on my computer, so I don’t know how the .MOD file can even run correctly?
Second, if I’m not supposed to open my data files, how can I check if the contents are the ones I need? Thank you!
Perfect, can you tell me also how can i create .MAT files? I have only .MAT file for Italy, but in my master’s thesis I want to analyze Slovenia and Austria too, however, I have data only in Excel format.
People read in the Excel files in a Matlab/Octave file, process the data and then save in in a mat
file (or directly use the m
-file as the data file).