Problems importing data

Hi, I have had problem importing data to Dynare:
please see attached are my excel file and mat file,

  1. I used the code
    a=xlsread(‘data’);
    save usmodel_data a

to tranform the xls data file into mat file

  1. I used the :
    estimation(datafile=usmodel_data,mode_compute=4, mh_replic=0);

command to import data to Dynare, while the error message says:
Error using load_mat_file_data_legacy (line 30)
makedataset: The variable(s) dy, dc, dinve, labobs, pinfobs, dw, robs listed in varobs are not contained in the dataset

usmodel_data.mat (11.0 KB)
data.xls (58 KB)

Please could anyone help me with the issue?

That will not work. You are saving only one matrix named a into the data file that you load. But Dynare expects several vectors with the name of the individual data series. Is there a reason you do not lead the Excel-file directly?

no reason, please could you provide more details regarding how to import from excel directly?

You should be able to use

datafile='data.xls' 

If necessary, also use the xls_range-option

1 Like

Hi prof, thanks for your reply,which has helped me resolve the issue.
Please could you help me with another question?
regarding the graphs produced by shock_decomposition command, the defaults uses different colours to differentiate different groups, is it possible to adapt it ( dashed, shaded, filled) to suit the black and white print?

Best

Dynare does not provide such an option. You either need to recreate the graph you desire based on the results in oo_.shock_decomposition or you can use Matlab’s figure editor to change the graph Dynare produces.

Hi dr jpfeifer I have problem with import my xls data to estimation code every time i get error :Error using load_xls_file_data
load_xls_file_data: I am not able to read the dates!

Error in load_data (line 49)
[~, init, data, varlist] = load_xls_file_data(filename, sheet, range);
this my codes line for this error :varobs y pi i;

% Load the data file (assuming ‘data.mat’ as an example filename)
% Make sure ‘data.mat’ contains a MATLAB table named ‘data’

% Define the estimated parameters
estimated_params;
beta, beta_pdf, 0.99, 0.02;
stderr eps_nu, normal_pdf, 0.01, inf;
end;

% Perform the estimation
estimation(datafile=[num,txt,raw]=xlsread(‘C:\Users\noahk\Downloads\Dissertation\Dynare\UKGDP…xls’), mode_compute=0, mh_replic=2000,
mh_nblocks=2, mh_drop=0.1, mh_jscale=2.5, conf_sig=0.95, bayesian_irf, irf=20);
could please help me out please

Without seeing the file it is impossible to tell.