[R] nlm doesn't detect a gradient in my function

Andrew Robinson andrewr at uidaho.edu
Sat Jul 17 00:22:47 CEST 2004


Hi R-community,

I wonder if anyone has dealt with this problem?  I've written a negative log-likelihood function of 4 parameters, and I want to minimize it. It doesn't have derivative information (it actually requires running an external program).  I can detect a gradient in it, e.g.:



> toy.likelihood.4.2(c(80.5, 43.0, 0.385, 6.5))
[1] 24664.62
> toy.likelihood.4.2(c(79.5, 43.0, 0.385, 6.5))
[1] 24657.32
> toy.likelihood.4.2(c(79.5, 43.0, 0.375, 6.5))
[1] 24669.77



but nlm can't detect a gradient in that region:



> unweighted.mle.1 <- nlm(toy.likelihood.4.2,
+                         c(80.5, 43.0, 0.385 6.5),
+                         hessian=T, print.level=2)
iteration = 0
Parameter:
[1] 80.500 43.000  0.385  6.500
Function Value
[1] 24664.62
Gradient:
[1] 0 0 0 0

Relative gradient close to zero.
Current iterate is probably solution.



Can anyone suggest a remedy?

Thanks much,

Andrew




More information about the R-help mailing list