Dear @jpfeifer,

I am trying to estimate a Loss function of the form Loss = var(inflation)+alpha*var(output), with var expressing variance and i am using the format i find in one of your models:

https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Gali_2015/Gali_2015_chapter_6_5.mod

Particularly i write the below and also declare Loss and a_Loss in the variables and paramaters block respectively.

variance.pie=oo_.var(pie_pos,pie_pos);

variance.Y=oo_.var(Y_pos,Y_pos);

Loss = variance.pie + a_Loss*variance.Y;

However, i am geeting the below error:

line 186, col 9 character unrecognized by lexer.

On the other hand if input the above under stoch_simul command i get the below error message:

line 254, cols 8-15: syntax error, unexpected VARIANCE.

Can you please help? Any idea?

You may also find attached the code

DSGE_loss_test.mod (7.1 KB)

Within the `model`

-block, you cannot access `oo_ `

or use structures. That part belongs outside of the block.

Thanks @jpfeifer for your answer.

However i add the part:

variance.pie=oo_.var(pie_pos,pie_pos);

variance.Y=oo_.var(Y_pos,Y_pos);

Loss = variance.pie + a_Loss*variance.Y;

After the model block and the received the error message:

Line 190…cols 8-15: syntax error, unexpected VARIANCE

Should i declare variance.pie and variance.Y somewhere, because i haven’t?

Any Other idea?

Please provide the updated version.

@jpfeifer, attached you may find the updated version.

DSGE_loss_test.mod (7.1 KB)

For pure Matlab code, use the `verbatim`

-block:

```
verbatim;
variance.pie=oo_.var(pie_pos,pie_pos);
variance.Y=oo_.var(Y_pos,Y_pos);
Loss = variance.pie + a_Loss*variance.Y;
end;
```

thanks @jpfeifer. I use the above block you mentioned, but i receive the below message:

ERROR: There are 39 equations but 40 endogenous variables!

Basically, i have declared (Loss) variable, but it seems that it doens’t recognize the equation Loss = variance.pie + a_Loss*variance.Y, this is why i probably get this message.

Any idea on how to overcome this error?

Attached the updated version.

DSGE_loss_test.mod (7.0 KB)

Again, my previous comment applies:

What exactly is your goal?

Thanks @jpfeifer for your reply.

I have it outsidw the model block, and use the verbatim block as you advise.

I want to calculate Bank loss for a variety of policy rules according to the variances/volatility of output and inflation after some shocks. So this is why i have this equation

loss = variance.pie + a_Loss*variance.Y which seems not to be rcognized (due to variance structures as you said)

But this is not supposed to be a separate model equation. This is simply Matlab code you append after the model based on the results of the model.

So as i understand i don’t need to use verbatim block.

How can i calculate Bank loss for a variety of policy rules using the variances of output and inflation after some shocks? Do i need to right some other way the bank loss equation?

Is there any way to model bank loss function using the calculated variance for Y and inflation each time? I thought that by using variance.pie, variance. Y variables i will get the calculated variance i was saying before.

Thanks Mike

My mod-file referenced above is a working code. I don’t understand why you cannot simply follow it.

@jpfeifer Thanks… I paid a bit more attention to the code and manage to solve it