Estimation: Problems whith reading the data from Excel

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Estimation: Problems whith reading the data from Excel

Postby makro » Wed Oct 21, 2009 9:32 am

Hi,

I'm trying to estimate a model (Comin & Gertler, Medium Term Business Cycles). But I always get the following error message:

??? Error using ==> cell.strmatch at 18
Requires character array or cell array of strings as inputs.

Error in ==> read_variables at 64
iv = strmatch(var_names_01(dyn_i_01,:),raw(1,:),'exact');

Error in ==> dynare_estimation_1 at 237
rawdata = read_variables(options_.datafile,options_.varobs,[],options_.xls_sheet,options_.xls_range);

Error in ==> dynare_estimation at 62
dynare_estimation_1(var_list,varargin{:});

Error in ==> mf_1_quart at 693
dynare_estimation(var_list_);

Error in ==> dynare at 102
evalin('base',fname) ;


I know that the error must be in the reading procedure as I looked around here in the forum. And the charts of the priors already show up.But I can't find my mistake. As an attachment you find my mod file and the excel file with the data.
I hope somebody can help me?!
Thanks a lot!
Attachments
usq_cg.xls
(37.5 KiB) Downloaded 283 times
mf_1_quart.mod
(11.78 KiB) Downloaded 375 times
makro
 
Posts: 1
Joined: Wed Aug 06, 2008 1:38 pm
Location: Essen

Re: Estimation: Problems whith reading the data from Excel

Postby pakocica » Sat Dec 05, 2009 9:56 am

Hi there,

I think that there are some bugs in the code of the function read_variables.m in the version 4.0.4.

First, you need to change the mod file. In the estimation set xls_range= a1:d232. The matlab build in function xlsread will automatically separate numbers from the variable names.

Next, click on the in the error message read_variables at 64. Matlab will open the file read_variables near the end of the file. Here you replace the original text be the following:

Code: Select all
  file_name_02 = [file_name_01 '.xls'];
    [b][num,txt] = xlsread(file_name_01,xls_sheet,xls_range);[/b]
    for dyn_i_01=1:var_size_01
      [b]iv = strmatch(deblank(var_names_01(dyn_i_01,:)),txt,'exact');
      dyn_tmp_01 = [num(1:end,iv)]';[/b]
      if length(dyn_tmp_01) > dyn_size_01 & dyn_size_01 > 0
   error('data size is too large')
      end
      dyn_data_01(:,dyn_i_01) = dyn_tmp_01;
    end


After this modification, I was able to run the file as far as to the error message:
Code: Select all
??? Error using ==> chol
Matrix must be positive definite.

Error in ==> metropolis_hastings_initialization at 54
d = chol(vv);

Error in ==> random_walk_metropolis_hastings at 43
[ ix2, ilogpo2, ModelName, MhDirectoryName, fblck, fline, npar, nblck,
nruns, NewFile, MAX_nruns, d ] = ...

Error in ==> dynare_estimation_1 at 942
        feval(options_.posterior_sampling_method,'DsgeLikelihood',options_.proposal_distribution,xparam1,invhess,bounds,gend,data);
       
Error in ==> dynare_estimation at 62
    dynare_estimation_1(var_list,varargin{:});

Error in ==> mf_1_quart at 694
dynare_estimation(var_list_);

Error in ==> dynare at 102
evalin('base',fname) ;


Good luck!
Pavel
pakocica
 
Posts: 46
Joined: Fri Nov 27, 2009 6:42 pm
Location: Taiwan (come from Prague)

Re: Estimation: Problems whith reading the data from Excel

Postby pawel » Mon Jul 04, 2011 6:56 pm

Not particularly timely, but I recently got a similar error and was slightly misled by the answer above...

For possible reference: I think the real reason this didn't work is because the first line of the data section in the excel file needs to contain the variable names. Which it did not in the example files attached. So, another way to get this to work is to modify the .xls file as follows
usq_cg.xls
(44 KiB) Downloaded 301 times

(and possibly the mod file accordingly).

Best,
p
pawel
 
Posts: 33
Joined: Fri Jan 05, 2007 11:16 am


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 11 guests