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.

penal.m (139 Bytes)

t1.mod (602 Bytes)

You should use

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.