Random starting points for mode-finding

Perfect, I opened xlsx file with

pkg load io
S = xlsread(‘Slovenia.xlsx’)

however it worked only first time, trying to do it again produces the following error:

error: parse error:

syntax error

Afterwards I plan to use the following transformation to .MAT format:

save Slovenia.mat S

That is not a full error message. Without more details or the files it is impossible to tell.

Here is full error message and file.

Data.xlsx (19.4 KB)

I don’t know why, if I try uploading Slovenia.xlsx, the file that uploads is the same but with different name: Data.xlsx.

Those are not the correct quotes for quoted strings. You need to use '.

Perfect, now it works.

How do I use this .MAT input file now? Do I replace it just in my Model8 file instead of “datafile=data1” I use “datafile=Slovenia” and in your code instead of “datafile=fs2000_data” I use again “datafile=Slovenia”?

What about in the second file that I need to run, “run.m”? I see no “datafile” command there, so where do I input the Slovenian data? Thank you.

Model8.mod (4.5 KB)
run.m (6.6 KB)
Slovenia.mat (10.9 KB)

I am not sure what you are doing.

  1. Your mat file is not a Matlab/Octave binary but instead just a plain text file. That won’t work. In that case, you need an m-file reading in the text.
  2. Yes, you need to pass the new datafile with the datafile-option in the estimation command.
  3. I can’t speak to the run.m. I haven’t written it. I provided you with the Dynare alternative of doing something like that in Random starting points for mode-finding - #10 by jpfeifer

Wow, so the following operation is done both by my run.m file and your paragraph?

“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”.”

Yes, the code

samples N times from the prior, runs mode-finding (ML), and stores the results.

Perfect. However, how do I create proper .MAT file? I used the following commands for transformation from .XLS into .MAT file:

pkg load io
A = xlsread(‘Austria.xlsx’)
save Austria.mat A

Your mat file must store the individual variables with the names they have in the mod-file.

Thank you! So the line:

varobs Dataitrobs Dataitpiobs Dataitmobs Dataitinobs Dataitcobs;
in Model8.mod (4.5 KB)

must be changed into:

varobs r_obs pi_obs m_obs in_obs c_obs

Do change also the following line?

Slovenia=[temp.Dataitrobs temp.Dataitpiobs temp.Dataitmobs temp.Dataitinobs temp.Dataitcobs];

Austria.mat (11.7 KB)
Austria.xlsx (18.1 KB)

No, because those variables are not defined in the context of our model. You need to read in the Excel file and assign its content to variables with the correct name.

Ah, so it’s the opposite! Excel must be changed and assigned names from mod file and not mod file changed with the names from Excel?

Is this correct now?

Model9.mod (4.5 KB)
Slovenia.xlsx (15.9 KB)
Slovenia.mat (10.9 KB)