# Introducing Covariances in the Objective Function of OSR

Dear Dynare Community,

I am working with optimal simple monetary and fiscal rules using the osr command. My objective function is a loss function and usually after running osr I compute the asymptotic loss and compare it with the osr objective function value. Although it is possible to introduce covariances in the osr objective function, I notice that when do it the asymptotic loss does not match the osr objective function value.

Example:

Suppose my objective function is: alpha*(y^2) + omega*(pi^2)

osr code:
optim_weights;
y alpha;
pi omega;
end;

In this case, the osr objective function value is the same as the asymptotic loss: alphavariance(y) + omegavariance(pi)

However, if my objective function is: alpha*(y^2) + omega*(pi^2) + 2chiy*pi

osr code:
optim_weights;
y alpha;
pi omega;
y,pi chi;
end;

In this case, the osr objective function value is not the same as the asymptotic loss: alphavariance(y) + omegavariance(pi) + 2chicovariance(y,pi)

Any help?

Best,

Paulo

There are two things at work.

First, you make a conceptual mistake. You minimize E(xWx) and in optim_weights the entries of W are determined. When setting

```optim_weights; y,pi chi; end;```
you only set one covariance term as the matrix W does not need to be symmetric. Thus, there is no 2* in front of the covariance matrix. For the 2* to be justified, you would need

```optim_weights; y,pi chi; pi,y chi; end;```

Second, there is a bug in Dynare, see github.com/DynareTeam/dynare/pull/767. A fix is attached
osr1.m (3.34 KB)
osr_obj.m (2.53 KB)
get_variance_of_endogenous_variables.m (1.73 KB)

Thanks. I will take that into account.

Best,

Paulo Vieira