Info

This question is closed. Reopen it to edit or answer.

Issues using fsolve while iterating

1 view (last 30 days)
Jose Pellerano
Jose Pellerano on 30 Oct 2012
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi, I'd appreciate any suggestion(s) on the following:
I'm using mle for my estimation but before evaluating my likelihood function I have to solve for an auxiliary parameter, r, that can be solved from a model condition given theta (theta1 and theta2).
Given theta1 and theta2 I have to solve for r from the following equation:
y = (((pmin-r)*100)/(((pmax - r)^2)*gampdf(gaminv((pmax-pmin)/(pmax-r),theta1,theta2),theta1,theta2)))-1;
In every iteration random numbers will be generated for both theta1 and theta2 within the specified bounds in fmin. I have to modify the code to take into account the following two issues:
1.Given theta1 and theta2 the equation above might not have a solution.
2.For fsolve’s initial guess the function might not be defined. It would help to restrict r to be within (0, pmin) but I can’t specify bounds for fsolve.
thanks in advance,
Jose

Answers (2)

Matt J
Matt J on 30 Oct 2012
Edited: Matt J on 30 Oct 2012
Use LSQNONLIN instead, which does let you specify bounds. Use the exitflag and the resnorm output arguments to determine if a solution was found.

Jose Pellerano
Jose Pellerano on 6 Nov 2012
thanks Matt, it seems to work.
Jose
  1 Comment
José-Luis
José-Luis on 6 Nov 2012
Please accept an answer if it helped you.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!