Page 1 of 1

Multiple shock periods

PostPosted: Fri Mar 01, 2013 8:21 pm
by mhlinder
Hi,

I am having trouble using a variable to store shock values for use in a mod file. Specifically, I am trying to recreate the following code example (found here: http://www.dynare.org/manual/index_18.html):

Code: Select all
xx = [1.2; 1.3; 1];

shocks;
var e;
periods 1:3;
values (xx);
end;


When I run this, I receive an error in
Code: Select all
set_shocks
"Subscripted assignment dimension mismatch." I've identified that, when Dynare generates the M-file corresponding to my mod file, a call is made to
Code: Select all
set_shocks
, which includes the line

Code: Select all
set_shocks(0,1:3, 1, xx);


The problem with this line is that, given the way set_shocks works, it is trying to set a 3x1 vector equal to a 9x1 vector. That is, because the range 1:3 has length 3, the vector xx is duplicated using repmat() 3 times, even though xx already contains 3 values.

One solution would be to write,

Code: Select all
xx = [1.2; 1.3; 1];

shocks;
var e;
periods 1 2 3;
values (xx(1)) (xx(2)) (xx(3));
end;


which works, but is a hassle for a large number of shock periods, and according to the Dynare manual, should be unnecessary.

Can anyone provide some guidance? Thanks so much.

Re: Multiple shock periods

PostPosted: Fri Mar 01, 2013 9:07 pm
by jpfeifer
Hi, could you please post or send me the whole mod-file. I have trouble replicating the issue.