[R] maximizing a likelihood function containing an integral

Ben Bolker bolker at zoo.ufl.edu
Mon Sep 11 15:08:54 CEST 2006

Sam Wong <qxsr <at> yahoo.com> writes:

> Hi, R Users;
> I am trying to maximize a likelihood function which
> contains an integral.  The integral contains the
> unknown parameter as well.  I am trying to use the
> following code to do the maximization:


> The error message is: 
> Error in log(x) : Non-numeric argument to mathematical
> function

   The only obvious (?) mistake in the code is that
you refer to integrate(...)$integral -- the help page
for ?integrate says that $value is the estimate of
the integral, so you might be getting a NULL here.

However, the code you gave us is not reproducible/self-contained -- since I don't
know what z1, z2, n1, rho are, I can't run it and see if that's the only 

    Ben Bolker

More information about the R-help mailing list