Creating Graphs through a static model

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.

Creating Graphs through a static model

Postby msh855 » Mon Sep 22, 2014 11:20 am

Hi,

I have a very simple question, but I do not know how to make it in Dynare. Assume, I have found the steady state of my model.

What I would like to do, is to create a graph where it shows how the steady state value changes when a particular parameter from the model changes. That is, I want to plot the relationship between a particular endogenous variable and a parameter of the model. Is there any command way on how to do it?

I am using Dynare 4.3.2 in Matlab. Any help on this will be much appreciated.
msh855
 
Posts: 39
Joined: Thu Feb 23, 2012 8:32 pm

Re: Creating Graphs through a static model

Postby jpfeifer » Mon Sep 22, 2014 1:29 pm

There is no built-in capacity to do so. You would need to loop over your parameter using Matlab and then extract the result. The general approach is shown here: http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=4891
------------
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: Creating Graphs through a static model

Postby msh855 » Mon Sep 22, 2014 6:55 pm

Thanks for the link.

I have created the following m.file in matlab

Code: Select all
sig=0.1:0.01:0.7;
mu=zeros(length(sigma1),1);

alpha=0.36;
A=0.25;
k2=(1-alpha)/alpha;
r=(1-alpha)*A*(k2)^alpha;
tauk=0.01;
tauh=0.2;
tau=0.2;
sigma2=(0.25)^2;

for i=1:length(sig);
sigma1=sig(i);
save parameterfile alpha A k2 r tauk tauh tau sigma1 sigma2
dynare model_bb_taxk
result=oo_.steady_state;
mu(i)=result(17,1);
end;


and my mod. file modified to include this:

Code: Select all
load parameterfile;
set_param_value('alpha', alpha);
set_param_value('A', A);
set_param_value('k2', k2);
set_param_value('r', r);
set_param_value('tauk', tauk);
set_param_value('tauh', tauh);
set_param_value('tau', tau);
set_param_value('sigma1', sigma1);
set_param_value('sigma2', sigma2);


But, matlab is returning the following errors:

Code: Select all
Undefined function 'sig' for input arguments of type 'double'.

Error in loop_sigma1 (line 14)
sigma1=sig(i);


if I take out the "mu(i)=result(17,1);" part of the m.file code. And returns the following error, when I include the aforementioned part:

Code: Select all
Subscript indices must either be real positive integers or logicals.

Error in loop_sigma1 (line 18)
mu(i)=result(17,1);


But, once i take the dynare my.file command the m.file runs perfectly.

Can you please suggest what I should amend ? It seems to me that i am doing something that confuses matlab once I include the dynare withing the loop.
msh855
 
Posts: 39
Joined: Thu Feb 23, 2012 8:32 pm

Re: Creating Graphs through a static model

Postby jpfeifer » Tue Sep 23, 2014 9:24 am

You should have followed my example, not the person I corrected. You are only trying to vary one parameter, sigma1. For this case, write a standard mod-file without loading a parameter matrix and then use
Code: Select all
clear all
sig=0.1:0.01:0.7;
mu=zeros(length(sigma1),1);
dynare model_bb_taxk noclearall %first call for setting up the environment

for i=1:length(sig);
    set_param_value('sigma1', sig(i)); %set parameter for subsequent runs
    info = stoch_simul(var_list_); %get the model solution including the steady states
    if info; %check whether model solution exists
      disp(['Computation fails for rho = ' num2str(sig(i))]);
    else
        mu(i)=oo_.steady_state(strmatch('Variable Name here',M_.endo_names,'exact'),1); %extract result using the variable name
    end;
 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


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 11 guests