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)

Dear professor,

I obtain the following error trying to run the above files:

ERROR: Model9.mod: line 143, cols 8-17: Unknown symbol: Dataslrobs.

Although the data variable Dataslrobs is clearly included in both Excel and mat file. So what could be the problem? Thank you!

Within your mod-file, no variable with the name Dataslrobs exists. You only have
Dataitrobs Dataitpiobs Dataitmobs Dataitinobs Dataitcobs

Perfect. I corrected the mistake and now everything seems to be working.

However, you mentioned that results with the output of the mod file are stored somewhere. I see no output file in my destination folder. Could you tell me where are the results stored (what’s the name of the output file)? Thanks in advance!

It is in the output folder and ends with _results.mod. But if you use my code above, you would need to save the mode_parameter structure manually at the end of your run.

Yes, I am using your code, could you please tell me how to save the mode_parameter structure?

After the first (out of three) step in my testing is done, I want to move to the second one:

  1. After we have found the starting values, the maximize the likelihood, we compute the standard errors of the estimated model parameters using a bootstrap approach. This is done by executing the script “booti.m”, which is placed in the folder “Computing Bootstrapped Standard Errors - Full Sample”

Perhaps, like for the first step, do you have again your code that I could use and bypass dr. Röhe’s code?

booti.m (12.0 KB)

  1. Add a line like

    save mode_parameter_results mode_parameter;
    

    at the end of the mod file

  2. No, I don’t have code for this and don’t even understand how that approach supposed to work. That type of bootstrapping is not usually done.

I ran the file successfully (I think), but there is no file that ends with _results.mod and no output folder on my machine.

Perhaps, this error code could be the problem?

Model10.mod (4.5 KB)

I found just one “Output” folder inside folder Model10, but it’s empty…