Fsolve and nonlinear equations

Hello Dynare community,

I’m relatively new to using fsolve, and I’ve encountered a new nonlinear equation when I introduced a new variable “t” into my model (and into my completed fsolve numerical solver). Specifically, the issue revolves around a nonlinear equation concerning “c_prime.” My question is whether it’s feasible to insert another fsolve to address this issue, or if I should approach it as a system of two unknown variables and then rewrite the whole.

I’m uncertain whether this is a syntax problem on my part or if I should treat it as a matrix involving two unknowns. I’m not entirely familiar with the syntax of fsolve, I’ve been trying out some examples I found, but I keep encountering errors. If anyone could provide some guidance or point me to some resources where I can learn more about the correct syntax and usage, I would greatly appreciate it.

Any guidance or suggestions on how to tackle this problem would be greatly appreciated.

Thank you in advance for your help.

solve_labor.m (1.5 KB)

You need to provide the full set of files. But yes, nested calls to fsolve should work. They just might not be very efficient.

Thank you for your prompt response and for your help! Below are the full set of files. I got stuck on the fsolve issue before making changes to the corresponding equations in the calibration file. Any help would be greatly appreciated.
benchqe1.mod (5.6 KB)
calib.m (2.3 KB)

You need

[c_prime,Fval,exitflag] = fsolve(@(c_prime)c_prime+r_star*b_prime_c_prime*c_prime+t-w_prime^2*c_prime^(-1),0.46);

to indicate the variable that is optimized over.

Thank you for your help! Fsolve works now and all steady states have been done. I put the same equations into the calibration files, but it finally shows:

There are 12 eigenvalue(s) larger than 1 in modulus
for 13 forward-looking variable(s)
The rank condition ISN’T verified!
Error using print_info
Blanchard & Kahn conditions are not satisfied: indeterminacy.

I’m uncertain whether this is because I use fsolve to find the value for c_prime, which then leads to the residual of equation 23 is not 0, or this might just because some uncovered timing errors or errors in manual steady state calculations.

calib.m (2.5 KB)

Thanks for your help again!

Your steady states look sensible. For that reason, I think there is an unrelated error, like a timing problem. But the residual in one equation may indicate that there is indeed still a mistake in the model as it does not conform to the steady state model you solved.