[R] integration error when I use "optim" and "integrate" simultaneously
kathie
kathryn.lord2000 at gmail.com
Sun Apr 27 01:04:32 CEST 2008
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]))
}
integrate(numint,lower=0,upper=Inf)$value
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.
More information about the R-help
mailing list