# Piecewise function not holding when estimating IRF

**URL:** <https://forum.dynare.org/t/piecewise-function-not-holding-when-estimating-irf/27863>\
**Category:** Stochastic simulations\
**Created:** [7 August 2025 12:38 UTC](https://forum.dynare.org/t/piecewise-function-not-holding-when-estimating-irf/27863 "2025-08-07T12:38:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Henry.Austin](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@Henry.Austin](https://forum.dynare.org/u/Henry.Austin)\
**Post date:** [7 August 2025 12:38 UTC](https://forum.dynare.org/t/piecewise-function-not-holding-when-estimating-irf/27863/1 "2025-08-07T12:38:00Z")

</div>

Hello there,

I’m estimating a model with a government policy rule in which the government intervenes with a wage subsidy.

The rule states the government will spend Gt = max(0, C\_bar - Ct). However, when I estimate the impulse response function, it says that the government responds to a positive economic shock with negative spending. I am trying to get it such that the government spendings nothing in response to a positive shock and only responds in response to a negative shock.

I’ve attached my .mod file and an image of the IRFs that are confusing.

Any help would be much appreciated.

Kind Regards,  
Henry  
[IRF.fig](https://forum.dynare.org/uploads/short-url/oJzTYaNL0Av7VOYsJ7kzLPbl6eN.fig) (40.9 KB)  
[wagesubsidy.mod](https://forum.dynare.org/uploads/short-url/6X8UH4QDsDlhXZQKHvvoqUCrZaC.mod) (2.8 KB)  
[wagesubsidysimul.m](https://forum.dynare.org/uploads/short-url/3RMv7stHat1gKgPNoMwGmEz4EFU.m) (1.6 KB)

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [11 August 2025 14:13 UTC](https://forum.dynare.org/t/piecewise-function-not-holding-when-estimating-irf/27863/2 "2025-08-11T14:13:26Z")

</div>

You cannot use perturbation solutions for non-differentiable functions. You could try to use OccBin.
