If statements within block 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.

If statements within block model

Postby cesco » Sat Jan 07, 2012 3:35 pm

Good morning I am a total newbie with Dynare, and I am trying to buid a simple model of debt dynamics.

I defined the equations in the model block, and one of these is the government reaction function, that determines spending according to its debt target.
I'd like to have an if statement. Something like:

if b<=60,
dcur=0;
invg=dsp;
else
dcur = delta1*0.05*(b0-bstar);
invg = chi0*dsp;
end;

This is what I'd do in a matlab code, but of course it did not work within dynare!

Is there any possibility to do it? In genera, is it possible to say the model to use certain equations at certain moments, and others at other moments?
Can I for example set some parameters at different values with if statements? (say if the central bank is conservative then the inflation parameter is such, if the central bank is not, then the inflation parameter is something else

thanks!
Francesco
cesco
 
Posts: 2
Joined: Sat Jan 07, 2012 3:28 pm

Re: If statements within block model

Postby cesco » Mon Jan 09, 2012 1:32 pm

I post an update:
I found that if statements can be included with @#if and so on. But it also seems to me that this can only work for parameter values, not for values taken by the endogenous variables.
In other words, I could solve the "monetary policy" question (if cb conservative do x, if cb loose, do y). But I cannot do what to me was more important, i.e. tell the model to change dynamic equation past a debt threshold.

I am afraid that the latter problem is unsolvable...
cesco
 
Posts: 2
Joined: Sat Jan 07, 2012 3:28 pm

Re: If statements within block model

Postby johannes.fritz » Tue Jan 17, 2012 3:56 pm

Dear Francesco

I am no expert on this but maybe it helps you find your way.

I share your interpretation for the usage of @#if. It's only useful to make distinctions a priori, not endogenously.

Maybe this gets you going:
In general, Dynare knows the following functions ("if" not being one of them):
http://www.dynare.org/DynareWiki/ListOf ... lFunctions

There is also the "external functions" command through which one can integrate other Matlab routines
http://www.dynare.org/DynareWiki/ExternalFunctions

Regards
Johannes
johannes.fritz
 
Posts: 4
Joined: Tue Jun 21, 2011 7:14 pm

Re: If statements within block model

Postby Sara » Tue Jul 21, 2015 5:32 pm

Hi,
I am wondering if you could solve the problem? I am facing something similar... I need to set an if statement which depends on a variable, but Dynare does not give me the solution! I get the error that FEx is unknown..

CFEx = (x-Cx(-1))/x;
FEx = CFEx^2;

@#if FEx(-1)>= 1
alpha_x = 0;
@#esle
alpha_x = (1-(FEx(-1))^2)^0.5;
end;
Sara
 
Posts: 1
Joined: Tue Jul 21, 2015 5:19 pm

Re: If statements within block model

Postby jpfeifer » Wed Jul 22, 2015 5:08 am

Sorry, but this is not possible within the context the stochastic simulations in Dynare. The reason is that your policy function will have a kink and be non-differentiable. This is inconsistent with perturbation solution techniques that rely on Taylor approximations.
------------
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 contributions and examples

Who is online

Users browsing this forum: No registered users and 1 guest