[R] Trouble with optim

Yang, Richard dyang at nrcan.gc.ca
Thu Jul 31 17:09:10 CEST 2003


Dear All;

	Searching on the achieve, many questions on optim() have been asked,
but I haven't seen the following.

	The question began with my original inquiry on "Optimization failed
in fitting mixture 3-parameter Weibul l distribution using fitdistr()" which
I posted on Jul. 28, Prof. Ripley kindly advised me to look into options of
optim() for the answer. Following his advice and constraining the location
parameters (a, and a1 in the mixture distribution of 3-parameter Weibull
density) in the objective function, my first attempt fitting the mixture
distribution seemed successful:

> mwb.test3 <- optim(c(0.6,8.87, 100, 4.0, 0.001, 89.1, 2.99), mwb3b.obj, x
= x5, hessian = T,
+          control = list(maxit = 2000))
Warning messages: 
1: NaNs produced in: log(x) 
2: NaNs produced in: log(x) 
3: NaNs produced in: log(x) 
4: NaNs produced in: log(x) 
5: NaNs produced in: log(x) 
6: NaNs produced in: log(x) 
7: NaNs produced in: log(x) 
8: NaNs produced in: log(x) 
9: NaNs produced in: log(x) 
10: NaNs produced in: log(x) 
> rbind(mwb.test3$par, se = sqrt(diag(solve(mwb.test3$hessian))))
        [,1]      [,2]      [,3]     [,4]    [,5]     [,6]     [,7]
   0.5367797  12.70957  91.05743 5.269290 3.26119 81.64733 2.506190
se       NaN 138.88411 135.21737 6.749831     NaN      NaN      NaN
Warning message: 
NaNs produced in: sqrt(diag(solve(mwb.test3$hessian))) 

	In an attempt to obtain se for the estimated parameters, I resorted
to the "L-BFGS-B" method:

> mixwb3.nl1 <- optim(p0, mwb3b.obj, wbmix.gr, method = "L-BFGS-B",
+              hessian = T,
+              lower = c(0, rep(0, 6)), upper = c(1, rep(Inf, 6)), x = x5)
> rbind(est = mixwb3.nl1$par, se = sqrt(diag(solve(mixwb3.nl1$hessian))))
             p        a        b         c        a1       b1        c1
est 0.50843845 4.519553 90.11219 3.0334775 0.6799724 88.06625 3.5105745
se  0.05461006 9.646768 11.02222 0.3451899 9.8708639 10.15148 0.1797819

	Everything looks fine and dandy,  but ...

> mixwb3.nl1$convergence
[1] 52
> mixwb3.nl1$message
[1] "ERROR: ABNORMAL_TERMINATION_IN_LNSRCH"

	So, my questions are:

	1) How to obtain se for estimated parameters from the Nelder-Mead
method?

	2) Is the error message in the L-BFGS-B method serious? How to
circumvent it?

	Any thoughts and suggestions?

	TIA,

Richard Yang

Northern Forestry Centre   /	Centre de foresterie du Nord
Canadian Forest Service	   /	Service canadien des forêts
Natural Resources Canada   /	Ressources naturelles Canada
5320-122 Street     	   /	5320, rue 122

Edmonton (Alberta) Canada
T6H 3S5




More information about the R-help mailing list