Problem in mcp equation

Hi everyone,

I’m now working on a heterogeneous model with CDF to solve it. An endogenous variable x, whose steady state value is negative, turns positive under the exogenous shock. And I then calculate the following:

y = 0.5 * (1+erf(max(0,x)))

as the CDF. As the stochastic simulation fails in this case, I write it as:

[mcp=‘x > 1e-6’]
y = 0.5*(1+erf(x));

But in the deterministic simulation, I still meet with the error
“Error using erf
Input must be real and full.”
Why could this happen? Didn’t I just restrict x to be larger than 0 in mcp?
Thank you for your help!

Best,
Marc

Sorry here should be y = 0.5*(1+erf(log(x)))

I would need to see the file.

Thank you for your reply!

I’ve attached my code below. The code is triggered by main00.m, and my question is in lines 102-108 of the mod file. Here, Z is the idiosyncratic tech of firms, and it follows log-normal distribution. Zdag is the cutoff under which some firms will fail. Under steady state, all firms are safe so Zdag is negative, whose numerator <0 and denominator >0.

And after we exert negative shock to RB, the numerator turns positive, so we can calculate nudag as the CDF of failing firms. (line 107 is calculated by internal function, line 108 is calculated by my self-defined external function, which is robust when input is negative ). As I ultimately need nudag = log(max(Zdag,0)), I have a mcp constraint. But if I use line 106-107, the code fails in evaluating steady-state by the error I meet above; if I use line 108 and simul, the simulation also fails as ‘NaN or Inf detected in the residuals or endogenous variables’. I also try to use Occbin, which fails again.

Thank you for your help!
Best,
Marc

Marc_Dynare_Code.rar (3.9 KB)

I may be missing something, but your steady state file returns Zdag=-3.48 and you are taking log(Zdag). How is that supposed to work?

Yes, in the steady-state the Zdag will be negative. And I hope nudag is the CDF of log-normal distribution once Zdag>0. So actually I need nudag = 0.5\times (1+erf(\frac{\log(\max{(Zdag,1e-6)})-\mu_z}{\sigma\sqrt{2}})), and thus its steady-state will be 0.

But you provide negative steady state values for Zdag and are calling steady to evaluate the steady state at this point.