Page 1 of 1

How External function works in the Dynare?

PostPosted: Fri Jun 23, 2017 4:17 pm
by inside
Would somebody explain me about my misunderstanding?
I have the some very easy rbc model.
I created penalty function (it's positive only if x<0, and eq=0 for x>0). It’s don’t have any influence on the model, I just put pen = penal(inv);
Why the IRF is so strange?
When I look on endo_simul, there is some problem: variable pen doesn’t equal penal(inv). It’s positive when inv positive too. Why is it?
How can I check, that the function work? I used debug and funtion work well.
Thank to everyone for help.

Re: How External function works in the Dynare?

PostPosted: Fri Jun 23, 2017 5:10 pm
by jpfeifer
You should use
Code: Select all
external_function(name = penal,nargs=1,first_deriv_provided,second_deriv_provided);

as your function has the derivatives as the further outputs. The wiggly behavior came from the second order approximation paired with a finite difference approximation to the derivatives.
However, the fundamental problem is that your function has a zero first and second derivative at the steady state and will therefore not react to anything. Moreover, there is a kink at 0 that will not captured by a Taylor approximation.