I have a CES parameter alpha_d which is very close to 1 (0.99999999999919). The simulations give me NAN. This causes a problem for Dynare because in some of my FOCs I have the (1-alpha_d) denominator, which causes me NaN. What should I do ?

There is nothing you can do about this. For all numerical purposes 0.99999999999919 is equal to 1. Usually, there exists a limit if the coefficient goes to 1, but you cannot rely on a computer to compute that limit. That needs to be done analytically.

Hi, If \alpha_d is the elasticity of substitution (you donâ€™t give any details) you can probably switch to a Cobb Douglas. This can be done with a condition in your code if you use different calibrations for this parameter in the same .mod file.

Initially alpha_d is equal to 0.97 with sigma_es being equal to 0.75. So there is no issue here.

I want to perform senstivity analysis on that sigma_es (the elasticity of sub between the two goods) and fix its value value close to perfect complementarity, letâ€™s say 0.1. But that value of sigma_es, gives me a value for alpha_d of 0.999999999919. My whole model is built to see the interaction between consumers durables and energy. So taking out energy from the CES function would discredit the model.

I think Iâ€™m just going to lower sigma_es to 0.45 for the sensitivity analysis so alpha-d does not get close too 1.

As @stepan-a and I said: you are moving extremely close to a limit case here: perfect complementarity. In that case, you end up with a Leontief production function. This leads to numerical problems. There are two ways to proceed:

Consider the exact limit case by computing it analytically instead of relying on numerics (what @stepan-a suggested in the form of a macro-processor case distinction)

Stay further away from the limit in order to avoid numerical issues (what you suggested)

Note that in the perfect complementarity case (with a Leontieff technology) you will have to use a min function, which is available in dynare language, but only makes sense with a perfect foresight model.With a local approximation you would always stay along a branch of the Leontieff function, this is the same issue as with the ZLB (non differentiable function). I do not know which steady state restrictions you use for calibrating \alpha_d, but did you try alternative formulation of the CES production (for instance as the one used in Barro Sala-i-Martinâ€™s textbook in section 1.3.4)?