Loading Initial Values from external file

Hi everyone,

I am wondering if it is possible to use values loaded from an external file (i.e. a .mat file) as starting points for a deterministic simulation in the initval; block.
My code involves estimating sequences of shocks using the Kalman Filter, and then using the smoothed variables in the last period of the estimation as the starting points for a deterministic simulation. I understand that I can write initivals by hand, but this is not convenient and is error-prone as I the model is very large.

In case this is possible, I’d like to know how to do it, or if anyone could point me to any example files, etc

Also, is it possible to load a vector of shocks in a deterministic simulation? I know how to load a single value for a shock (you just define that value as a parameter, which can be loaded from an external file), but I haven’t been able to load a vector of shocks (i.e. different values at different periods). Thank you.

Thank you,

I believe that this option (datafile in simul) would address my issue, but there is lack of documentation and I do not know how to structure the files.

Have you tried smoother2histval?

The documentation is not clear about this, but in principle you can load a matfile before the model block and use it to initialize the shocks. Let us say that xtfile.mat contains the variable xt, 1-by-100. A way of doing this is the following:

xthatvalues = log(xt) - mean(xt);


var xhat;
periods 1:100;
values (xhatvalues);

It then initializes the shocks for a predetermined simulation, where the shocks were calculated using a matfile.

I am not sure if this method works in every application. Reply if you find problems.

@andre That will work, but only for the shocks-block, not for initval. Also, the loading can be done after the model-block.

1 Like