Performing an estimation of parameters using real data


I have successfully run my model with 7 shocks: productivity shocks, three tax rate shocks, two government spending shocks and monetary policy rate shock (interest rate shock in Taylor rule).
The data sample available is very scanty. I have annual data for 18 years on GDP, government spending (consumption and capital expenditure), interest rate, debt … as many as I have shocks or exogenous variables in my model. I would like to know whether it is possible to perform the parameter estimation using a very small sample with annual data.


That is not ideal, but doable. The prior distribution will msot probably play an important role in this case, i.e. the data will not be very informative.


Hi Professor,
Given that the sample size is very short, is it possible to apply filtering method to detrend some observable variables such as GDP and government spending in other to perform the estimation?


Why do you want to use a filter? First differences would be a filter you can use or a deterministic linear of quadratic trend.


I did try to perform the estimation of the parameter using the very short sample of data I have on the observables in first difference. I saved the data set and run the code but it can’t read the name of the variable as stated in the code. Here is the error message I got:
Error using load_mat_file_data_legacy (line 30)
makedataset: The variable(s) y, pi, gc, gi, s, d, r listed in varobs are not contained in the dataset

I don’t understand how come the code can read the variables’ names though I ave written them in the excel sheet and save as Matlab file for the code to read the variable names.
Could you provide me with a hint on how I could solve that issue?


Please provide the codes


Here is the .mod file and the data set/Med902e.mod (5.8 KB)
data12.mat (12.6 KB)


The data12.mat contains a bunch of Dynare structures, but no data. Load it into Matlab to see this.


Perhaps I did not save it on Matlab in appropriate way. I tried to use the spreadsheet format (Excel) but not successful. could you assist me in that? How to specify the excel data file.


estimation(datafile='macrodataset.xlsx',xls_sheet=Sheet1,xls_range = A1:G109)


I entered the code as follows:
estimation(datafile=‘data1.xls’, xls_sheet=data, xls_range=A2:G18)
Here is the error message I got
You did not declare endogenous variables after the estimation/calib_smoother command.
Error using dseries/extract (line 61)
dseries::extract: Variable y is not a member of A!
Error in dseries/subsref (line 236)
_ B = extract(A,S(1).subs{:});_

And other error message
It looks like the code cannot read the data from the data set I declare.


Please provide the Excel-file


Hi professor,
I can’t attach Excel file to the post. Therefore, compressed the file in order to attach it the (7.5 KB)

Something wrong with forecasting

Your range must include the variable names: xls_range=A1:G18


Hello Professor,
I included the variable naùes as recommended. However, the code could not perform the estimation and the following message does appear when I run the code.
Error using initial_estimation_checks (line 143)
initial_estimation_checks:: The forecast error variance in the multivariate Kalman filter became

Error in initial_estimation_checks (line 143)
_ error('initial_estimation_checks:: The forecast error variance in the multivariate Kalman_
_ filter became singular.’)_

I don’t really know why.


That means that your model implies an exact linear combination between at least two of the observables. That is a fundamental problem. My guess is that
causes the problem as you observe all three and this restriction will not hold in the data.


Hi professor,
After deleting this variable (s) from the observables and using only y, pi, d and r as observables, I still encounter the same issue of error message. The code can only generate the prior distribution but cannot go further to generate the posterior distribution and parameters means. I am really confused and can’t find a solution for that. Though it is more interesting to take my model to the data and find out how best it maps the real data. That is the main challenge I have for my paper. See the error message below:

Error using checkArgsForHandleToPrint
Handle input argument contains nonhandle values.

Error in checkArgsForHandleToPrint

Error in print>LocalCreatePrintJob (line 97)
handles = checkArgsForHandleToPrint(0, varargin{:});

Error in print (line 38)
[pj, inputargs] = LocalCreatePrintJob(varargin{:});

Error in dyn_saveas (line 42)

Error in plot_priors (line 73)
dyn_saveas(hplt,[M_.fname 'Priors’ int2str(plt)],options.nodisplay,options_.graph_format);

Error in dynare_estimation_init (line 323)

Error in dynare_estimation_1 (line 116)
dynare_estimation_init(var_list_, dname, [], M_, options_, oo_, estim_params_, bayestopt_);

Error in dynare_estimation (line 105)

Error in Med902e (line 343)

Error in dynare (line 223)
evalin(‘base’,fname) ;


Does your model work with just 1 observable?


HI Professor,
Following your hint, I tried to perform the estimation using only GDP (y) as observable. I observed that it works somewhat. But it could not show the posterior distribution graph because of some error message. I got an output from the estimate which I retrieved in a file to share it with you. I think this might provide more insight on the challenge I am (2.6 KB)
The prior graph are plotted but nothing appears on the screen regarding the posterior distribution.


There is still something wrong.

Initial value of the log posterior (or likelihood): -99440891490.6431

indicates that there is a problem for the initial parameter values. The big number is due to an error code. Are you using Dynare 4.5?