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.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to