Re optimal simple rules -- mistake re covariances

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Re optimal simple rules -- mistake re covariances

Postby christie.smith » Fri Aug 01, 2014 1:29 am

There still seems to be a mistake in the osr command in the latest (stable) version of Dynare. (I am using 4.4.2 on a Mac at home, and version 4.4.2 on Windows at work.)

The problem is that when a covariance is added in the welfare or loss function (as in the mod example below), the preprocessing of the mod file into the Mat file yields non-unique elements in obj_var_. This vector is passed to the ors function (the vector is renamed i_var) and then gets passed to the osr1 function which calls osr_obj (passing a reordered i_var vector to ors_obj), which then computes the welfare function by computing variances and covariances using the following two lines of code:

vx = get_variance_of_endogenous_variables(dr,i_var);
loss = weights(:)'*vx(:);

In the example below vx should be 3 by 3, but it ends up being a 4 by 4 matrix, conformable with the 4 by 4 weights matrix.
full(weights)
ans =
1.0000 0 0 1.0000
0.5000 1.0000 1.0000 0.5000
0.5000 1.0000 1.0000 0.5000
1.0000 0 0 1.0000

The weights matrix gets conformably messed up in the call to ors_obj (line 61 of osr1):
[loss,vx,info,exit_flag]=osr_obj(t0,i_params,inv_order_var(i_var),weights(i_var,i_var));

The bug can, I believe, be fixed by adding the following at the beginning of the osr function
i_var=unique(i_var);

Though ideally the dynare prepocessing would apply the unique command to obj_var_

Regards,
Christie


% Example Mod file taken from http://www.dynare.org/manual/index_29.html

var y inflation r;
varexo y_ inf_;

parameters delta sigma alpha kappa gammarr gammax0 gammac0 gamma_y_ gamma_inf_;

delta = 0.44;
kappa = 0.18;
alpha = 0.48;
sigma = -0.06;

gammarr = 0;
gammax0 = 0.2;
gammac0 = 1.5;
gamma_y_ = 8;
gamma_inf_ = 3;

model(linear);
y = delta * y(-1) + (1-delta)*y(+1)+sigma *(r - inflation(+1)) + y_;
inflation = alpha * inflation(-1) + (1-alpha) * inflation(+1) + kappa*y + inf_;
r = gammax0*y(-1)+gammac0*inflation(-1)+gamma_y_*y_+gamma_inf_*inf_;
end;

shocks;
var y_; stderr 0.63;
var inf_; stderr 0.4;
end;

optim_weights;
inflation 1;
y 1;
y, inflation 0.5;
end;

osr_params gammax0 gammac0 gamma_y_ gamma_inf_;
osr y;
christie.smith
 
Posts: 2
Joined: Thu Jul 31, 2014 11:43 pm

Re: Re optimal simple rules -- mistake re covariances

Postby christie.smith » Fri Aug 01, 2014 1:32 am

Correction: vx should be 2 by 2, not 3 by 3 in the example I provided.
Christie
christie.smith
 
Posts: 2
Joined: Thu Jul 31, 2014 11:43 pm

Re: Re optimal simple rules -- mistake re covariances

Postby jpfeifer » Tue Aug 05, 2014 9:09 am

We are going to look into this. But this seems to be no problem, because the objective function is just multiplied by 4, meaning that the minimum stays the same.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 8 guests

cron