I’m currently facing a few issues when using macro-language in Dynare. I would appreciate any help or insights!
1. How to Access Elements in a MATLAB Vector Using Macro Language?
I tried to extract an element from a MATLAB vector using macro-language, but it resulted in an error. Here’s what I attempted:
xx = [1; 2; 3];
@define x1 = xx(1)
This approach did not work as expected. How can I correctly access the first element of the xx vector within a macro definition?
2. Accessing Elements from a Macro-Defined Vector
In another case, I defined a vector directly in the macro language and wanted to retrieve its first element. The following code also produced an error:
@define xx = [1, 2, 3]
@define x1 = @{xx(1)}
3. Error When Using Macro-Defined Vectors in the shocks Block
I’m encountering a syntax error when trying to define a shocks block using macro-defined vectors. Here’s the code I wrote:
@#define xx = [3.1, 3.5]
@#define leg = length(xx)
shocks;
var x;
periods 1:@{leg};
values @{xx};
end;
What is the ultimate goal you are trying to achieve?
The is not a use-case that is supported. At runtime of the macroprocessor, the content of the Matlab variable is not yet known. Depending on what you are trying to do, there may be other ways to implement it.
In fact, I am currently trying to perform a perfect foresight simulation of an RBC model using an exogenous TFP sequence, possibly with a trend.
I would like to set the steady state in initval to correspond to the initial value of the TFP sequence, use the middle part of the sequence in shocks, and set the steady state in endval to the final value of the TFP sequence.
I’ve managed to run the simulation by setting everything manually, but I’m hoping to write the code more elegantly using the macro language.
Now I understand this is much complicated than I think. But still, I appreciate your kindly help!