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.

MSSF_steadystate.m (3.62 KB)

MSSF.mod (12.2 KB)

Use the macro-processor:

[code]@#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;

[/code]

Thanks a lot for your help.

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.

MSSF_VAR_forecast_2_steps_steadystate.m (3.64 KB)

MSSF_VAR_forecast_2_steps.mod (18.2 KB)