I was wondering how to pass the name of the data file into the .mod file? Essentially, I want to run something like
for i = 1:N
...
dynare model.mod (in which estimation(datafile = filename[i]); )
... (record the results)
end
Thank you!
This is adding some lines to some files. So what you mean is to create a new mod file every time in the loop? OK, thanks.
No, have a file e.g. called
estimation_statement.txt
included in your mod-file with
@#include "estimation_statement.txt"
Then alter that file using the for-loop:
for ii=1:size(filenames,1)
%write equation to file
fid=fopen('estimation_statement.txt','w');
fprintf(fid,'estimation(datafile = %s)\n',filenames{ii,1});
fclose(fid);
%run file
dynare my_modfile noclearall
%save results
save('results_',num2str(ii)])
end
1 Like
I see, through a macro. Thanks a lot for that clarification!