Expression in option_periods

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.

Expression in option_periods

Postby abman10 » Tue Jun 14, 2016 6:21 pm

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.
Attachments
MSSF_steadystate.m
steady_state file
(3.62 KiB) Downloaded 102 times
MSSF.mod
model
(12.15 KiB) Downloaded 118 times
abman10
 
Posts: 14
Joined: Thu Jan 15, 2015 3:22 am

Re: Expression in option_periods

Postby jpfeifer » Fri Jun 17, 2016 5:45 pm

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;
------------
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

Re: Expression in option_periods

Postby abman10 » Sat Jun 18, 2016 1:26 pm

Thanks a lot for your help.
abman10
 
Posts: 14
Joined: Thu Jan 15, 2015 3:22 am

Re: Expression in option_periods

Postby abman10 » Tue Jun 28, 2016 3:37 am

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.
Attachments
MSSF_VAR_forecast_2_steps_steadystate.m
steady_state
(3.64 KiB) Downloaded 108 times
MSSF_VAR_forecast_2_steps.mod
model
(18.19 KiB) Downloaded 121 times
abman10
 
Posts: 14
Joined: Thu Jan 15, 2015 3:22 am


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 8 guests