# News Shocks and Optimal Simple Rules

Hello,
I want to replicate the paper “news shocks and optimal simple rules” - 2010 ( Wohltmann & Winkler).

My problem is the loss function, which is
Loss = Var(πt − γπt−1) + αx Var(xt − δxt−1) (Page 9 Eq. 23)
The loss function contains lags. Dynare doesnt accept lags and leads and gives me always an error. I usually used a loss function of the form: 1/2*(pi^2+lambda*x^2)

Can u help me to solve this problem? How can I transform the loss function?

You need to define the lagged variables as variables in the model. E.g.

model;
pi_lag=pi(-1);
x_lag=x(-1);
end;


and use those in the loss function.

Thx a lot. It works now…
I want to run the model but I have a problem in the loss. My loss value is completely different than the loss from the paper.
My loss is L=0.817 and the one from the paper is L= 0.0899. So a huge difference but I cant find my mistake. I checked all equations and variables but couldnt find my mistake.
I used for delta the smalller root of the quadratic equation, which is 2.220446049250313e-16.
Is there anything I did wrong?

Newsneu.mod (1.7 KB)

And when I change the anticipation of the cost push shock from eps to eps(-3) there is no change in the loss. It is still the same amount as before… So there must be something wrong in my code…

I will try to help by tomorrow evening. At a first glimps it seems to be you are only interested in the loss value under commitment and not the OSRs, right?.

I haven´t reviewed your code yet. But maybe the paper is wrong.

By the way, I rely on the published version from 2011 and not the working paper.
I hope that there are no differences, otherwise communication might be difficult.

Hi Max1,
I am also interested on the OSR’s but at first I wanted to solve the problem with the loss.
I tried to find the OSR but dynare says my system is not stable (Blanchard kahn condition is not satisfied). So, I guess my code is wrong.

I think there are no differences between the paper.

As fare as I see there are multiple parameters which are wrongly specified. e.g. \kappa_3. I will help you and correct the typos I can spot.

I will upload the corrected code in 1 hour.

Are you sure that \delta = 2.220446049250313/ 10^{16}.?

If you set
a = \frac{h \sigma}{(1-\beta h)(1-h)}
and
b = \eta + \frac{\sigma}{(1-\beta h)(1-h)}(1+\beta h^2)
you obtain from equation (26)

a + a\beta \delta^2 - b \delta = 0
\delta^2 - \frac{b}{a\beta}\delta + \frac{1}{\beta} =0

The smaller root should be
\delta_2 = \frac{b}{2 a \beta} - \sqrt{ {(\frac{b}{2 a \beta})}^2- \frac{1}{\beta} }
for which I obtain 0.81871.

here is my correction of your code: NewsShock_WW.mod (2.3 KB)

and my guess about the root smaller_root.m (183 Bytes)

Unfortunately, I obtain Loss = 0.23296 and not 0.0899 as in the paper.

@jpfeifer are the authors wrong with the loss?

I found a mistake from my side
NewsShock_WW.mod (2.3 KB)

Now I obtain Loss = 0.090097

I could not find any further mistake in the code.

The loss is now very close to the one in the paper.
Maybe one can explain the difference with some numerical imprecision ?

Since Johannes helped me a lot in the past, I hope I could help you with your problem.

Best regards,
Max

Thanks alot!

I checked your code and it makes more sense now.
But I have one question: from where did u get the value for oo_.var(pi_pos,pi_lag_pos) . Its 0.0018. Is it the covariance of Pi and Pi_lag?

For the optimal simple rule: it= f(πt ,xt) for tau=0 and
gamma_pi= 1.5
gamma_x = 0.5
I get the Loss = 0.1087
Do u have a similar result?

yes, oo_.var stores the variance-covariance matrix of all model endogenous variables.

I guess you refer with gamma_pi and gamma_x to your starting values for the numerical optimizer, right?

Please post your code, otherwise I can not help you with the OSR. Unfortunately, I do not have enough time this weekend and I am not working on that paper.

Yes, they are my starting values.

My code for OSR:newsosr.mod (1.9 KB)

@jpfeifer Do u have any idea because of the difference between the loss from the paper and the code?

I corrected my optimal weights:

%optimal Simple Rule
optim_weights;
pi 1;
x a_x;
pi_lag 1;
x_lag a_x;
end;
and have a Loss = 0.0965

My questions are:
What should I do with the coeffiecients gamma and delta from the loss function? And do I need to state the covariances of
pi, pi_lag 1;
x,x_lag a_x ;
also as optimal weights?

Covariances appear in the loss, so they must be defined in the optim_weights block.