Warning: Maximum likelihood estimation did not converge. Function evaluation limit exceeded.

72 views (last 30 days)
I get the warning: Warning: Maximum likelihood estimation did not converge. Function evaluation limit exceeded.
Which relationship does
opt = statset('MaxIter',1e5,'MaxFunEvals',1e5,'FunValCheck','on');
have to my code? Especially the part: 'MaxIter',1e5,'MaxFunEvals',1e5. Because thats why the warning displays I think.
(I tried to understand in the documentary, I didnt understand. Maybe also because of my english).
The number of warnings changes everytime I change the parameter. Like when I change n or b_A or T_A.
PS: I am estimating a 2 and 3 parameter weibul distribution. I excluded the 2parameter version, for better overview. If you see somethin is not right with my code, I am thankful for every advice :)
clear all;
n = 100;
t0 = 0.2;
b_A = 1:5;
T_A = 1:5;
LowerBound= [0 0 0];
rng('shuffle');
data3p = zeros(n,length(b_A),length(T_A));
params3p = zeros(length(b_A),length(T_A));
Ergebnis3p = double.empty(length(b_A)*length(T_A), 0);
for k= T_A
for i= b_A
data3p(:,i,k) = wblrnd(i,k, [n,1]) + t0;
start = [i k t0];
custompdf = @(x,a,b,c) (x>c).*(b/a).*(((x-c)/a).^(b-1)).*exp(-((x-c)/a).^b);
opt = statset('MaxIter',1e5,'MaxFunEvals',1e5,'FunValCheck','on');
params3p(i,1:3,k) = mle(data3p(:,i,k),'pdf',custompdf,'start',start,'Options',opt,'LowerBound',LowerBound,'UpperBound',[Inf Inf min(data3p(:,i,k))])
params3p(i,4,k) = i;
params3p(i,5,k) = k;
params3p(i,6,k) = t0;
end
Ergebnis3p((k-1)*length(b_A)+1:k*length(b_A), 1:size(params3p, 2)) = params3p(:,:,k);
end

Accepted Answer

Tom Lane
Tom Lane on 22 Jun 2020
Since the random numbers vary, it makes sense that the number of iterations will also vary so the number of warnings may change.
The reason there are controls over both MaxIter and MaxFunEvals is that there are times when one is more of a contraint than the other, for example when an iteration is expensive versus when a function evaluation is expensive. In this case I would expect there to be many function evaluations per iteration, as the code tries to comptute numeric derivatives by evaluating the function in multiple places.
I suspect the issue here is that the likelihood of a three-parameter Weibull distribution can be unbounded, so parameters may drift toward infinity. If the shape parameter of the distribution is less than 1, then the density diverges toward infinity as the x value approaches 0, or as it approaches the lower limit of a three-parameter distribution. So you can see that as you allow the lower limit to get closer to the minimum observed data value, the contribution to the likelihood from that point goes to infinity.
One approach is to use an estimation method other than maximum likelihood. Take a look at the section "A Threshold Parameter Example" here:

More Answers (0)

Community Treasure Hunt

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

Start Hunting!