Page 1 of 1

Expression in option_periods

PostPosted: Tue Jun 14, 2016 6:21 pm
by abman10
Hi,

I am trying to simulate data from a DSGE model, which is instantenousely hitted by several shocks. Indeed, shocks arrive form period 1 to n. When giving an integer number to n (n=500), my program runs well. However, the program shows error when n is an expression:


periods 1:expression ;

instead of

periods 1:n ;

My question: Is there a way to introduce expression into n instead of an integer number?

To see more my problem, you find attached my codes.

Re: Expression in option_periods

PostPosted: Fri Jun 17, 2016 5:45 pm
by jpfeifer
Use the macro-processor:
Code: Select all
@#define n=500
test1=normrnd(0,0.0001,@{n},1);
test2=normrnd(0,0.0001,@{n},1);
test3=normrnd(0,0.0001,@{n},1);
test4=normrnd(0,0.0001,@{n},1);
test5=normrnd(0,0.0001,@{n},1);
test6=normrnd(0,0.0001,@{n},1);


shocks;
var a_shk ;
periods 1:@{n};
values (test1);

var x_shk ;
periods 1:@{n};
values (test2);

var up_shk ;
periods 1:@{n};
values (test3);

var uw_shk ;
periods 1:@{n};
values (test4);

var r_shk ;
periods 1:@{n};
values (test5);

var g_shk ;
periods 1:@{n};
values (test6);

end;

Re: Expression in option_periods

PostPosted: Sat Jun 18, 2016 1:26 pm
by abman10
Thanks a lot for your help.

Re: Expression in option_periods

PostPosted: Tue Jun 28, 2016 3:37 am
by abman10
A second question:

Can we use usual functions like sqrt or floor within macro-expression?

For example:

@# define k=1/2
@# define m=39
@# define n=floor(k*m)

To see my exact problem, you find attached the following files: Go to line 388 in model file.

Thanks a lot.