Hi all,

I am on a learning curve on macro processor.

I am trying to calculate yield to maturity (ytm) formula as follows based on a consumption CAPM model. The goal is to plot ytm against i. I tried this code.

…

@#define J=30

@#for i in 1:J

ytm=betta^-1*(c(+i)/c)^(1/i);

@#endfor

…

I get an error message.

Symbol c is being treated as if it were a function (i.e., takes an argument that is not an integer).

I must be doing something silly.

Hi,

You should read the section devoted to the macro language in the reference manual:

dynare.org/manual/index_37.h … g-language

If you rewrite the statement inside the loop as

```
ytm = (c(@{i})/c)^(1/@{i})/betta;
```

it should work better… You cannot use directly use the index i, you have to include it in @{}, as in other macro expression.

Best,

Stéphane.

Thank you Stephanne. Yes I am reading it. i am on a steep learning curve on this. The complication now is that it creates 435 auxiliary variables and thus number Of eqns far exceeds the number of variables. I believe I have to now declare all these new variables at the top usung macro processor.

Sorry, I didn’t really think about what is in the loop. Here you put an equation in the loop, so you create thousands of equation. I am quite sure that this is not what you intend. The equal sign should not be in the loop. I suppose you want to use this loop to write a product (or a sum) of terms in an equation. Perhaps it would be easier if you write what you want to compute…

Best,

Stéphane.

Dear Stephane,

Here is what I want to do. I would like to research what happens to ytm of various maturities. with respect to some monetary policy shock? That is why I wanted to create an array of ytm and then run an irf for each.

I can easily create manually 10 or 15 ytm variables and do this experiment. But I wanted to use the macro processor. But doing so, it gives rise to 400 auxiliary variables.

PB

I still don’t understand and would need to look at the equations. With this loop you add equations without adding variables, so obviously it cannot work. Do you mean that you need different variables on the left hand side (this would work)? To do that, you could try something like:

```
ytm_@{i} = (c(@{i})/c)^(1/@{i})/betta;
```

assuming that you have another loop in the list of declared endogenous variables (to declare ytm_1, ytm_2, …).

Best,

Stéphane.