<FONT face="Default Sans Serif, Verdana, Arial, Helvetica, sans-serif" size=2><DIV>Dear list members,</DIV><DIV> </DIV><DIV>I am trying to use "nlm" function to maximize a mixture likelihood of beta densities. There are five unknown parameters in the likelihood. Since I can get the analytic gradient, I attach the "gradient" attribute in my target likehood function. The code is as the following </DIV><DIV> </DIV><DIV> target <- function(x)</DIV><DIV> { resp <- ....</DIV><DIV> grad <- rep(0,5) ## I have 5 paramters</DIV><DIV> grad[1] <- ...; grad[2] <- ...; grad[3] <- ...; grad[4] <- ...; grad[5] <- ...</DIV><DIV> attr(resp, "gradient") <- grad</DIV><DIV> resp<BR> }</DIV><DIV>nlm(targ, c(1,2,3,4,5))</DIV><DIV>The R gave me this error message</DIV><DIV> </DIV><DIV>VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV</DIV><DIV>"Error in nlm(targ, c(1,2,3,4,5)) : probable coding error in analytic gradient"</DIV><DIV>^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</DIV><DIV>I ran my code for defining gradient separately, and there seemed to be no coding error. I provided other options for nlm() function and it gave me the same error message. I removed the gradient part and let nlm() do the numerical derivative, it ran but the algorithm was not converging. </DIV><DIV> </DIV><DIV>I want to know if nlm can handle multiple parameters problems, and if yes, was there any error in my code? How do I properly provide the gradient for my function? </DIV><DIV> </DIV><DIV>Thanks a lot,</DIV><DIV> </DIV><DIV> </DIV><DIV>Yuan Ji, Ph.D.<BR><BR>############################################<BR>Assistant Professor<BR>Department of Bistatistics<BR>The University of Texas M.D. Anderson Cancer Center<BR>1515 Holcombe Blvd. - Unit 447<BR>Houston, TX 77030-4009<BR>(713)794-4153<BR>############################################<BR></DIV></FONT>