LOOPING OVER PARAMETERS

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.

LOOPING OVER PARAMETERS

Postby marlenemaya » Mon May 08, 2017 8:46 am

Hi to everyone, I,m trying to solve a basic stochastic new keynesian model. It works, but my objective is to run it changing the value of a parameter. I've tried to use the command set_param_value within a loop, but it doesn't work. I've tried it with dynare or also using matlab: in any case the loop works but the value of the parameter doesn't change. The code is simply run n times without any change. Here there is my code. Can someone help me?
thank you
maya
Code: Select all
//IN THIS CASE IS CONSIDERED THE CASE WITH SYMMETRY IN PRICE ADJUSTMENT
close all
//QUESTIONE e E variabili che non riesco ad identificare
///////////////////////////////////////////////////////////////////////////
//DEFINITION OF VARIABLES


var p,ss,y,y_f,pp,pp_f,s,mu,mu_f;
varexo eps_mu,eps_muf;
parameters sigma,zeta, n, sigmas,epsilon,bbeta,theta,theta_f,eta,rho_mu,rho_muf,kappa,kappa_f,ggamma,lambda,lambda_f,yb,yb_f,sb;


theta=2;
sigma=1;
zeta=0.67;
n=0.5;
epsilon=7.66;
bbeta=0.99;
theta_f=0.75;
eta=2;
lambda=0.75;
lambda_f=0.75;
rho_mu=0.9;
rho_muf=0.9;
kappa=((1-theta*bbeta)*(1-theta))/(theta*(1+epsilon*zeta));
kappa_f=((1-theta_f*bbeta)*(1-theta_f))/(theta_f*(1+epsilon*zeta));
ggamma=(lambda+lambda_f)*(2-lambda-lambda_f)*sigma*eta+(1-lambda-lambda_f)^2;
sigmas=((sigma*eta-1)/sigma)*(2-lambda-lambda_f)*ggamma;
//omega=(((lambda+lambda_f)*(2-lambda-lambda_f)*(sigma*eta-1)*(sigma+zeta))/omega)*kappa;
sb=0;
yb=((lambda+lambda_f)*(2-lambda-lambda_f)*sigma*eta+(1-lambda-lambda_f)^2)/sigma;
yb_f=((lambda+lambda_f)*(2-lambda-lambda_f)*sigma*eta+(1-lambda-lambda_f)^2)/sigma;

///////////////////////////////////////////////////////////////////////////
//SPECIFICATION OF THE MODEL

 
model(linear);
pp=bbeta*pp(+1)+(sigma+zeta)*kappa*(y-yb)-lambda*(2-lambda-lambda_f)*(sigma*eta-1)*kappa*(s-sb)+kappa*mu;
pp_f=bbeta*pp_f(+1)+(sigma+zeta)*kappa_f*(y_f-yb_f)+lambda_f*(2-lambda-lambda_f)*(sigma*eta-1)*kappa_f*(s-sb)+kappa_f*mu_f;//AGGREGATE SUPPLY
ggamma*s=sigma*(y-y_f);
s-s(-1)=pp_f-pp;
0=(n*(y-yb)+(1-n)*(y_f-yb_f))+epsilon*(n*pp+(1-n)*pp_f);
mu=rho_mu*mu(-1)+eps_mu;
mu_f=rho_muf*mu_f(-1)+eps_muf;
p=pp-pp_f;
ss=s-sb;
end;


initval;
mu=0;
mu_f=0;
y=yb;
y_f=yb_f;
pp_f=0;
pp=0;
s=0;
ss=0;
pp=0;
end;


steady;
check;






shocks;
var eps_mu=0.1;
var eps_muf=0.1;
end;

stoch_simul(nodisplay,irf=51);

for i = 1:2
load parameterfile
set_param_value('theta',theta(i));
stoch_simul(order=1);
end   

i also have the .m file by which I've created the parameterfile.mat
Code: Select all
theta=[1,2]

save parameterfile theta
marlenemaya
 
Posts: 19
Joined: Mon Nov 21, 2016 3:56 pm

Re: LOOPING OVER PARAMETERS

Postby jpfeifer » Mon May 08, 2017 10:06 am

Your mod-file is not handling parameter dependence correctly. Theta enters kappa, but kappa is hardcoded instead of a model-local variable. See e.g. https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Gali_2015/Gali_2015_chapter_3.mod for a proper example.
------------
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: LOOPING OVER PARAMETERS

Postby marlenemaya » Mon May 08, 2017 5:46 pm

thank, you, now the model seems to work. I should now add the welfare function using the command planner_objective_value. I had to vary the value of the parameters because the aim was to plot the value of the welfare losses as function ot that parameter theta.
1 I don't know exactly how to store results for every repetion of the loop
2 the output of the command 'planner_objective_value', ''Approximated value of planner objective function'', what I think I,ve to plot, remains the same in every case. what's wrong?
thank you
marlenemaya
 
Posts: 19
Joined: Mon Nov 21, 2016 3:56 pm

Re: LOOPING OVER PARAMETERS

Postby jpfeifer » Wed May 10, 2017 1:13 pm

Please provide the most recent version of the codes in a zip-file
------------
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