[R] non-numeric argument in mle2
bbolker at gmail.com
Thu Apr 19 21:58:19 CEST 2012
peter dalgaard <pdalgd <at> gmail.com> writes:
> On Apr 19, 2012, at 09:52 , Joachim Audenaert wrote:
> > Hi all,
> > I have some problems with the mle2 function
> >> RogersIIbinom <- function(N0,attackR3_B,Th3_B)
> >> RogersII_B <-
> > mle2(FR~dbinom(size=N0,prob=RogersIIbinom(N0,attackR3_B,Th3_B)/N0),
> > Error in dbinom(x, size, prob, log) :
> > Non-numeric argument to mathematical function
> > Can somenone explain met what this error means? All my parameters and data
> > are defined, so I don't understand what the non-numeric argument is???
> > With different equations the script does work...........
> traceback() indicates that the prob= argument is a vector of
> complex numbers when doing the call
> minuslogl(attackR3_B = -0.262499999999999, Th3_B = 1.755625)
Further debugging shows that this is caused by an attempt
to evaluate a negative attack-rate parameter.
The short answer is that if you use method="L-BFGS-B",
lower=1e-5 (you need to set the lower bound slightly *above* zero)
you can get this to work fine.
I have posted a longer, somewhat obsessive answer at
which is an ongoing brain dump/set of notes about fitting
the Rogers random predator equation and related models in R.
More information about the R-help