deterministic simulations

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.

deterministic simulations

Postby canzonem » Sun May 30, 2010 2:57 pm

Hi:

I have been successfully running the following shock code:

//SHOCKS.
shocks;
var m;
periods 1:3;
values 2;
end;

It works fine. But I want to let the shock values for m go from 1 to 2 to 3 and then level off permanently at 2. Does anyone know how to do this?

Thanks for any help!
canzonem
 
Posts: 1
Joined: Sat Jan 14, 2006 9:14 pm

Re: deterministic simulations

Postby otb » Tue Jun 01, 2010 3:13 pm

You can specify the permanent change in the exogenous variable in the endval block. You still need the temporary changes in the shocks block.
otb
 
Posts: 26
Joined: Mon Apr 07, 2008 4:47 pm

Re: deterministic simulations

Postby isa350 » Wed Jun 09, 2010 1:18 am

Hi all
I'm trying to simulate macroeconomic model which has 29 equations. every time I run the model I got the following message:

>> dynare test3;

Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.

Starting Dynare (version 4.1.1).
Starting preprocessing of the model file ...
Found 9 equation(s).
Evaluating expressions...done
Computing static model derivatives:
- order 1
Computing dynamic model derivatives:
- order 1
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.

Warning: Divide by zero. This warning will be removed in a future release.
Consider using DBSTOP IF NANINF when debugging.
> In solve1 at 120
In dynare_solve at 112
In steady_ at 124
In steady at 52
In test3 at 152
In dynare at 132
??? Error using ==> lnsrch1 at 53
Some element of Newton direction isn't finite. Jacobian maybe singular or there is a problem with initial values

Error in ==> solve1 at 127
[x,f,fvec,check]=lnsrch1(xold,fold,g,p,stpmax,func,j1,j2,varargin{:});

Error in ==> dynare_solve at 112
[x,info]=solve1(func,x,j1(r(i):r(i+1)-1),j2(r(i):r(i+1)-1),jacobian_flag, bad_cond_flag, varargin{:});

Error in ==> steady_ at 124
[oo_.steady_state,check] = dynare_solve([M_.fname '_static'],...

Error in ==> steady at 52
steady_;

Error in ==> test3 at 152
steady;

Error in ==> dynare at 132
evalin('base',fname) ;

.................................................................................................................
and the model as it is in the Matlab file :

var nod cp ip kp kpstar g ig kg ih kh icap kcap tx bd mp xn mn y yp m p wp w nos f ox c l t;
varexo cg kgstar khstar kcapstar e oa po pstar ystar op rstar r nosp rstarf pi em;
parameters beta1 beta2 beta3 beta4 beta5 beta6 beta7 beta8 beta9 beta10 beta11 beta12 beta13 beta14 beta15 beta16
gamma delta rho sigma lambda nu mu1 mu2 epsilon1 epsilon2 epsilon3 epsilon5 epsilon6 epsilon7 tau psi1 psi2 phi1 phi2 phi3 phi4 phi5
alpha1 alpha2 alpha3 zeta;
beta1 = 1.00;
beta2 = 1.00;
beta3 = 1.00;
beta4 = 1.00;
beta5 = 1.00;
beta6 = 0.66;
beta7 = 0.54;
beta8 = 0.50;
beta9 = 0.40;
beta10 = 0.10;
beta11 = 1.00;
beta12 = 0.70;
beta13 = 0.47;
beta14 = 7.03;
beta15 = 0.74;
beta16 = 0.26;
gamma = 0.70;
delta = 0.85;
rho = 0.70;
sigma = 0.70;
lambda = 0.70;
nu = 0.60;
epsilon1 = 0.41;
epsilon2 = 0.36;
epsilon3 = 0.10;
epsilon5 = 1.00;
epsilon6 = 1.00;
epsilon7 = 1.00;
tau = 0.20;
mu1 = 0.60;
mu2 = 0.20;
psi1 = 0.68;
psi2 = 0.65;
phi1 = 0.08;
phi2 = 0.27;
phi3 = 0.59;
phi4 = 0.22;
phi5 =0.23;
alpha1 = 0.15;
alpha2 = 0.57;
alpha3 = 0.32;
zeta = 0.20;


model;
nod = beta1*cp+beta2*ip+beta3*g+beta4*xn-beta5*mn;
cp = beta6*nos+beta7*wp;
ip = gamma*(kpstar-kp);
(kp-kp(-1)) = gamma*(kpstar-kp);
kpstar = delta*nos;
g = beta8*cg+beta9*ig+beta10*ih+(1-beta9-beta10)*icap;
ig = rho*(kgstar-kg);
(kg-kg(-1)) = rho*(kgstar-kg);
ih = sigma*(khstar-kh);
(kh-kh(-1)) = sigma*(khstar-kh);
icap = lambda*(kcapstar-kcap);
(kcap-kcap(-1)) = lambda*(kcapstar-kcap);
bd = beta11*((m-m(-1))-(p-p(-1)));
tx = beta12*(oa+po+e-p)+(1-beta12)*nos;
xn = beta13*(e+pstar-p)+beta14*ystar;
mn = beta15*y-beta16*(e+pstar-p);
y = nu*nos+(1-nu)*oa+(1-nu-mu2)*po+(mu1-nu)*(e-w)-(1-mu1-mu2)*pstar;
yp = nu*nosp+(1-nu)*op+(1-nu-mu2)*po+(mu1-nu)*(e-w)-(1-mu1-mu2)*pstar;
m = epsilon1*nos-epsilon2*pi-epsilon3*r+p;
wp = epsilon5*kp+epsilon6*(m-p)+epsilon7*nosp;
(m-m(-1)) = tau*(r-rstar+(f-f(-1)));
p = mu1*w+mu2*(e+po)+(1-mu1-mu2)*(e+pstar);
(w-w(-1)) = psi1*(nod-nos)+psi2*(m-m(-1));
nos = phi1*kp+phi2*kg+phi3*kh+phi4*kcap+phi5*em;
(f-f(-1)) = alpha1*t+alpha2*(rstar*f)+alpha3*(ox-po)-(1-alpha2-alpha3)*(e-p);
ox = zeta*(oa-y);
c = e-w;
l = m-w;
t = xn-mn;
end;

initval;
nod=10;
cp=7;
ip=7;
kp=3;
kpstar=3;
g=12;
ig=7;
kg=7;
ih=5;
kh=5;
icap=4;
kcap=4;
tx=3;
bd=0;
mp=2;
xn=3;
mn=5;
y=10;
yp=10;
m=7;
p=0.23;
wp=7.54;
w=5;
nos=11;
f=12;
ox=12;
c=0.70;
em=0;
t=8;
cg=11;
kgstar=0;
khstar=0;
kcapstar=0;
e=0.88;
oa=0;
po=0;
pstar=0;
ystar=0;
op=0;
rstar=0.05;
r=0.04;
nosp=10;
pi=0.06;
l=3;
end;

steady;

check;


shocks;
var oa;
periods 1:9;
values 0.1;
end;

stoch_simul(periods=2100);


so, any help would be appreciated.

Issa Ali
isa350
 
Posts: 4
Joined: Wed Jun 09, 2010 1:01 am

Re: deterministic simulations

Postby StephaneAdjemian » Wed Jun 09, 2010 10:12 am

Dear Issa, This is probably a problem in your model (or you are very unlucky with the initial conditions declared in the initval block). The jacobian of the the static model (where lags and leads are replaced by contemporaneous variables) is singular (I found to zero eigenvalues).

Best, Stéphane.
Stéphane Adjemian
Université du Maine, GAINS and DynareTeam
https://stepan.adjemian.eu
StephaneAdjemian
 
Posts: 429
Joined: Wed Jan 05, 2005 4:24 pm
Location: Paris, France.

Re: deterministic simulations

Postby isa350 » Thu Jun 10, 2010 2:55 pm

Dear Stephane
thank you very much for your reply. Actually I played around the equations and the run Dyanrae again. I only got steady stae results and eigenvalues.

var nod cp ip kp kps g ig kg ih kh icap kcap tx xn mn dm y yp m p wp w nos f ox c l t;
varexo cg kgs khs kcaps e oa po ps ys op rs r nosp rsf pi em;
parameters beta1 beta2 beta3 beta4 beta5 beta6 beta7 beta8 beta9 beta10 beta11 beta12 beta13 beta14 beta15 beta16
gamma delta rho sigma lambda nu mu1 mu2 epsilon1 epsilon2 epsilon3 epsilon5 epsilon6 epsilon7 tau psi1 psi2 phi1 phi2 phi3 phi4 phi5
alpha1 alpha2 alpha3 zeta;
beta1 = 1.00;
beta2 = 1.00;
beta3 = 1.00;
beta4 = 1.00;
beta5 = 1.00;
beta6 = 0.66;
beta7 = 0.54;
beta8 = 0.50;
beta9 = 0.40;
beta10 = 0.10;
beta11 = 1.00;
beta12 = 0.70;
beta13 = 0.47;
beta14 = 7.03;
beta15 = 0.74;
beta16 = 0.26;
gamma = 0.70;
delta = 0.85;
rho = 0.70;
sigma = 0.70;
lambda = 0.70;
nu = 0.60;
epsilon1 = 0.41;
epsilon2 = 0.36;
epsilon3 = 0.10;
epsilon5 = 1.00;
epsilon6 = 1.00;
epsilon7 = 1.00;
tau = 0.20;
mu1 = 0.60;
mu2 = 0.20;
psi1 = 0.68;
psi2 = 0.65;
phi1 = 0.08;
phi2 = 0.27;
phi3 = 0.59;
phi4 = 0.22;
phi5 =0.23;
alpha1 = 0.15;
alpha2 = 0.57;
alpha3 = 0.32;
zeta = 0.20;


model;
nod = beta1*cp+beta2*ip+beta3*(beta8*cg+beta9*ig+beta10*ih+(1-beta9-beta10)*icap)+beta4*xn-beta5*mn;
cp = beta6*nos+beta7*wp;
ip = gamma*(kps-kp);
kp-kp(-1) = gamma*(kps-kp);
kps = delta*nos;
ig = rho*(kgs-kg);
kg-kg(-1) = rho*(kgs-kg);
ih = sigma*(khs-kh);
kh-kh(-1) = sigma*(khs-kh);
icap = lambda*(kcaps-kcap);
kcap-kcap(-1) = lambda*(kcaps-kcap);
g = tx+beta11*((m-m(-1))-(p-p(-1)));
tx = beta12*(oa+po+e-p)+(1-beta12)*nos;
xn = beta13*(e+ps-p)+beta14*ys;
mn = beta15*y-beta16*(e+ps-p);
y = nu*nos+(1-nu)*oa+(1-nu-mu2)*po+(mu1-nu)*(e-w)-(1-mu1-mu2)*ps;
yp = nu*nosp+(1-nu)*op+(1-nu-mu2)*po+(mu1-nu)*(e-w)-(1-mu1-mu2)*ps;
m = p+epsilon1*nos-epsilon2*pi-epsilon3*r+p;
wp = epsilon5*kp+epsilon6*(m-p)+epsilon7*nosp;
dm = tau*(r-rs+(f-f(-1)));
p = mu1*w+mu2*(e+po)+(1-mu1-mu2)*(e+ps);
(w-w(-1)) = psi1*(nod-nos)+(psi2*dm);
nos = phi1*kp+phi2*kg+phi3*kh+phi4*kcap+phi5*em;
(f-f(-1)) = alpha1*t+alpha2*(rs*f)+alpha3*(ox-po)-(1-alpha2-alpha3)*(e-p);
ox = zeta*(oa-y);
c = e-w;
l = m-w;
t = xn-mn;
end;

initval;
nod=1;
cp=5;
ip=0.5;
kp=9;
kps=9;
g=1;
ig=0.5;
kg=9;
ih=0.5;
kh=8;
icap=0.5;
kcap=6;
tx=3;
xn=3;
mn=5;
dm=0;
y=10;
yp=10;
m=7;
p=0.23;
wp=7.54;
w=5;
nos=11;
f=12;
ox=12;
c=0.70;
em=4;
t=8;
cg=11;
kgs=9;
khs=9;
kcaps=9;
e=0.88;
oa=15;
po=10;
ps=0.6;
ys=0.7;
op=3;
rs=0.05;
r=0.04;
nosp=10;
pi=0.06;
l=10;
end;

steady;

check;

shocks;
var oa; periods 1:9;
values 0.1;
end;

stoch_simul(periods=2100);
.....................................................................................

>> dynare test2

Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.

Starting Dynare (version 4.1.1).
Starting preprocessing of the model file ...
Found 28 equation(s).
Evaluating expressions...done
Computing static model derivatives:
- order 1
Computing dynamic model derivatives:
- order 1
- order 2
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.


STEADY-STATE RESULTS:

nod 11.4182
cp 48.7451
ip 0
kp 9.70386
kps 9.70386
g -14.8287
ig 0
kg 9
ih 0
kh 9
icap 0
kcap 9
tx -14.8287
xn -18.803
mn 24.0239
dm -0.002
y 14.7298
yp 9.08
m 108.568
p 51.9565
wp 76.3154
w 82.4742
nos 11.4163
f 139.941
ox 0.0540429
c -81.5942
l 26.0939
t -42.8269

EIGENVALUES:
Modulus Real Imaginary

0 -0 0
0 -0 0
0.5882 0.5882 0
0.5882 0.5882 0
0.5882 0.5882 0
0.6052 0.6052 0
0.9281 0.9281 0
1.029 1.029 0


There are 1 eigenvalue(s) larger than 1 in modulus
for 0 forward-looking variable(s)

The rank conditions ISN'T verified!

??? Error using ==> dr1 at 198
2nd and 3rd order approximation not implemented for purely backward models

Error in ==> resol at 128
[dr,info,M_,options_,oo_] = dr1(dr,check_flag,M_,options_,oo_);

Error in ==> stoch_simul at 42
[oo_.dr, info] = resol(oo_.steady_state,0);

Error in ==> test2 at 399
info = stoch_simul(var_list_);

Error in ==> dynare at 132
evalin('base',fname) ;

>>
isa350
 
Posts: 4
Joined: Wed Jun 09, 2010 1:01 am

Re: deterministic simulations

Postby horvathar » Fri Jun 18, 2010 8:54 am

Hello HQ,
I'm a beginner trying to build a deterministic model starting from the basics.

- - - - -
var hs;
predetermined_variables hs;
varexo s;

parameters beta;
beta=0.2;

model(linear);
hs(1)=hs*beta+s;
end;

initval;
hs=100;
s=80;
end;
steady;

endval;
hs=200;
s=160;
end;
steady;

simul(periods=20);
rplot hs;
pause;
close all;
- - - - -

And it gives a constant hs=200.

What do I do wrong?
Thank you, Aron (Budapest, Hungary)

During my trials from time to time I get the message:
??? Attempted to access lead_lag_incidence(3,:); index out of bounds because size(lead_lag_incidence)=[2,1].
What does it mean?
horvathar
 
Posts: 5
Joined: Sun Aug 05, 2007 2:58 pm
Location: Budapest

Re: deterministic simulations

Postby isa350 » Sun Aug 29, 2010 5:41 am

Dear all

I conducted a deterministic simulation for macroeconomic model assuming two different shocks. I'm just wondering how can I plot the same variable, using rplot, from different shocks in one graph.

thanks
Issa
isa350
 
Posts: 4
Joined: Wed Jun 09, 2010 1:01 am

Re: deterministic simulations

Postby SébastienVillemot » Mon Aug 30, 2010 9:24 am

Sorry, I don’t understand your question. Please elaborate.

Do you mean that you want the contribution of each shock to the path of your variable of interest ? If yes, then this is not feasible (unless your model is linear), since contributions are not additive. All you can do is run a separate simulation for each of the shocks at a time, and then a simulation with both shocks.
Sébastien Villemot
Economist at OFCE – Sciences Po
SébastienVillemot
 
Posts: 706
Joined: Fri Dec 07, 2007 2:29 pm
Location: Paris, France

Re: deterministic simulations

Postby isa350 » Tue Aug 31, 2010 4:00 am

Thanks for your reply. Actually I ran a separate simulation for each of the shocks ( oil production shock and oil price shock) and I have got a separate graph for each variable of interest. I would like, for examble, to compare beteew the impact of the oil production shock upon, for examble the foreign asset stock, with the impact of the oil price shock upon the same variable in the same graph, rathur than having two graphs.
note that I applied permanent shock.

Any help would be appreciated

thanks
isa350
 
Posts: 4
Joined: Wed Jun 09, 2010 1:01 am

Re: deterministic simulations

Postby SébastienVillemot » Mon Sep 13, 2010 9:19 am

Hi,

For doing this, you need to learn how to create graphs with MATLAB, using the family of plot commands. Dynare will not do that automatically, you must program a little bit.

The idea is that for each of your simulation, Dynare solves the path of all endogenous in variable “oo_.endo_simul”, in a file which ends with “<FILENAME>_results.mat” where <FILENAME> is the name of your MOD file.

So what you need to do is to create a script which, for each of the two simulations, loads the results file and retrieves the path of your variable of interest from oo_.endo_simul. Then you can plot the two paths on the same graph using the “plot” command from MATLAB.

Hope this helps,
Sébastien Villemot
Economist at OFCE – Sciences Po
SébastienVillemot
 
Posts: 706
Joined: Fri Dec 07, 2007 2:29 pm
Location: Paris, France

Re: deterministic simulations

Postby rouillajf » Fri May 05, 2017 4:51 am

Hi all,

I'm trying to simulate a deterministic model. I want to model a shock (x) that takes different values over time.
x_1=1.2
x_2=1.3
x_3=1.4
...
x_24=1.5 and x_24+k=1.5 (for k>0). All shocks are perfectly fore-sighted in period 0. I'm not sure what's the best way to write it up in the shocks section.

Thanks for your help,
JF
rouillajf
 
Posts: 1
Joined: Fri Apr 17, 2015 5:01 am

Re: deterministic simulations

Postby jpfeifer » Fri May 05, 2017 5:51 am

Which problem do you encounter when you use the shocks block listing the shocks?

With the unstable version, you could also run
Code: Select all
perfect_foresight_setup
first and then manually set the entries in
Code: Select all
oo_.exo_simul

before running
Code: Select all
perfect_foresight_solver
------------
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: Google [Bot] and 11 guests