Date: Thu, 9 Dec 1999 13:03:27 +0000 (GMT) From: Bill Simpson Subject: [R] nlm() problem or MLE problem? I am trying to do a MLE fit of the weibull to some data, which I attach. fitweibull<-function() { rt<-scan("r/rt/data2/triam1.dat") rt<-sort(rt) plot(rt,ppoints(rt)) a<-9 b<-.27 fn<-function(p) -sum( log(dweibull(rt,p[1],p[2])) ) cat("starting -log like=",fn(c(a,b)),"\n") out<-nlm(fn,p=c(a,b), hessian=TRUE) xfit<-seq(min(rt),max(rt),(max(rt)-min(rt))/100) yfit<-pweibull(xfit,out$estimate[1], out$estimate[2]) lines(xfit,yfit,lty=2) yfit2<-pweibull(xfit,a, b) lines(xfit,yfit2) list(out=out) } I got the starting values a=9, b=.27 from fitting the Weibull CDF by eye to a quantile plot of the data. The final values fitted by nlm() are a= 4.8299357, b= 0.2753897 I plotted both CDFs against the quantile plot of the data. I would have expected the MLE fit to be the one that lies closer to the data. NO. The MLE solution (dashed) seems to fit quite badly in comparison with my starting values (solid). I wonder if this is just the way MLE is, or is there a problem with nlm() here? There are numerous warnings from nlm(). But the starting values are said to give a terrible -log likelihood, which is hard to believe. I am using R 65.1 under Linux. Thanks for any help! Bill PS when I do dweibull(rt,9,.27) the last value is 1.003383e-173 I guess this one observation in the right-hand tail is dominating the fit?! It contributes 173 to the -log likelihood The nlm() fit to this last point gives 1.550882e-10. What to do?