[R] integration error when I use "optim" and "integrate" simultaneously

From: kathie <kathryn.lord2000_at_gmail.com>
Date: Sat, 26 Apr 2008 16:04:32 -0700 (PDT)

Dear R users,

When I use two functions, 'optim' and 'integrate', simultaneously, I always get an error like this

numint = function(z) {

        dlnorm(z,mu[1],sqrt(exp(g[1]))) *
dnorm((z-mu[2])/sqrt(exp(g[2])))/sqrt(exp(g[2])) }


Error in integrate(numint, lower = 0, upper = Inf) : non-finite function value

Dr. Ripley said for this problem long time ago

"You are trying to use a derivative-based optimization method without supplying derivatives. This will use numerical approximations to the derivatives, and your objective function will not be suitable as it is internally using adaptive numerical quadrature and hence is probably not close enough to a differentiable function (it may well have steps)."

So, I am trying to avoid this 'integrate' in R, but I have no idea.

Any suggestion will be greatly appreciated.

Kathryn Lord

View this message in context: http://www.nabble.com/integration-error-when-I-use-%22optim%22-and-%22integrate%22-simultaneously-tp16918109p16918109.html
Sent from the R help mailing list archive at Nabble.com.

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sun 27 Apr 2008 - 00:54:29 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 27 Apr 2008 - 07:30:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive