close all 
% 1. Declaration des variables et paramètres.
var produit inflation interet conso infetr prodetr intetr  inf_imp inf_dom ; 
varexo  export tot  cmim cmdom  inta phit epsid epsint vet epsiv  epsiprodetr epsiinfetr epsiintetr changedev epsit epsiuip change; 
parameters alpha x beta nu teta_dom teta_imp  tetaun tetadeu tetatroi habit sigma rho  gamif gamit gamp   rhod rhov sigepsid sigepsiint  sigepsiv sigepsiprodetr sigepsiinfetr sigepsiintetr rhoepsi; 
% 2. Parameters calibration (values from estimation) 
beta =0.982; 
x=0.01;
alpha =0.40; 
nu =1.5; 
teta_dom =0.5; 
teta_im =0.5 ;
rho=0.75;
rhod=0.5; 
gamif =1.50; 
gamit =0.70; 
gamp =0.7; 
sigepsipetr=1;
sigepsiitetr=1;
sigepsiifetr=1;
sigeepsi_regim=1;
rhopetr=0.5;
rhoifetr=0.5;
rhoitetr=0.5;
habit=0.7;
teta_imp=0.5;
tetaun=0.5;
tetadeu=0.5;
tetatroi=0.5;
sigma=1.5;
rhov=1;
sigepsid=1;
sigepsiint=1;
sigepsiv=1;
sigepsiprodetr=1;
sigepsiinfetr=1;
sigepsiintetr=1;
rhoepsi=1;


% 3. Description du modèle d’analyse
model(linear); 
produit=(1-alpha)*conso+alpha*export+(2-alpha)*nu*tot+alpha*nu*phit ;
conso= (1/(1-habit))*(conso(+1)-habit*conso)-((1-habit)/sigma)*(inta-inflation(+1)-((1-rhoepsi)*(1-habit)/(1-habit)*sigma)*epsit);
inf_imp =beta*(1-teta_imp)*inf_imp(+1) + teta_imp*inf_imp(-1)+((1-beta*teta_imp)*(1-teta_imp)/teta_imp)* cmim;
inf_dom=beta*(1-teta_dom)*inf_dom(+1)+teta_dom*inf_dom(-1)+((1-beta*teta_dom)*(1-teta_dom)/teta_dom)*cmdom;
inflation=(1-alpha)*inf_dom+alpha*inf_imp;
interet=rho*interet(-1)+(1-rho)*(gamif*inflation+gamp*produit+gamit*(change-change(-1)))+epsint;
prodetr=tetaun*prodetr(-1)+epsiprodetr;
infetr=tetadeu*infetr(-1)+epsiinfetr;
intetr=tetatroi*intetr(-1)+epsiintetr;
end;
% 4. Defining initial values, end values and shocks 
% (shocks values from estimation) 
initval; 
produit=-7; 
interet=18; 
inflation=4; 
end; 
endval; 
produit=0; 
interet=0; 
inflation=0; 
end; 
shocks; 
var epsiintetr=sigepsiintetr^2; 
var epsiinfetr =sigepsiinfetr ^2;  
var epsiprodetr = sigepsiprodetr ^2; 
end;
%5. Réalisation d’une simulation stochastique 
stoch_simul(linear,periods=20000,relative_irf,ar=10);
