[R] bbmle: mle2: initial value in 'vmmin' is not finite

Ben Bolker bbolker at gmail.com
Thu Aug 8 05:21:55 CEST 2013


Thomas Cameron <tom.cameron <at> emg.umu.se> writes:

>  Dear R users 

> I am trying to estimate parameter values for function
> using optim in the mle2 function in the bbmle package but I cannot
> get past the above error message.
 
 [snip]
 
> # load packages
> library(bbmle)
> library(emdbook)
> 
> # specify the model
> rogers.pred = function(N0, a, h, P, T) {
>   N0 - lambertW(a * h * N0 * exp(-a * (P * T -
>   h * N0)))/(a * h)
> }
> 
> #write the liklihood function
> NLL.rogers = function(a, h, T, P) {
>   if (a < 0 || h < 0)
>   return(NA)
>   prop.exp = rogers.pred(Initial, a, h, P, T)/Initial
>   -sum(dbinom(Killed, prob = prop.exp, size = Initial,
>   log = TRUE))
> }
> 
> # specify the data
> P = 0.03125  # there is only one predator, this is the predator density/Litre
> N0 = rep(c(0.25,0.5,0.75,1), each=5) # density of prey/Litre
> Initial = N0
> Time= c(29.28, 54.85, 46.22, 38.81, 21.35, 11.03, 
>  28.69, 12.47, 43.28, 12.46, 38.81, 21.35, 81.03,
> 75.77, 13.01, 9.47, 6.51, 4.64, 12.59, 26.47) 
> # time taken to kill first 5 prey
> Killed=5

> # place the data in a frame
> fr2<-data.frame(Killed, P, N0, T, Initial)
> 
> # supply the liklihood function with starting values and run the model
> FRR.rogers = mle2(NLL.rogers, start=list(a = 0.2, h=0.5), data=fr2)
> summary(FRR.rogers)
> 
> #OUTPUT
> Error in optim(par = 0.1, fn = function (p)  :     # I GET THIS ERROR ALWAYS
>   initial value in 'vmmin' is not finite
 
  Short answer: you need N0 to be an integer (i.e. number of prey,
not density of prey per litre) if you're going to use it as the 'size'
parameter in a binomial likelihood.  (I haven't tried that yet to
see if that fixes everything, or if there are problems beyond that
step.)  
   I'm a little bit nervous about using this model for your
experimental design (time how long it takes for the first 5 prey
to be eaten -- the usual statement of the problem is number of
prey eaten in a *fixed* time, and the statistical properties
might be different).  If the predation probability were fixed this
would be Gamma distributed, but I'm not sure how it works out with
depletion ...

  Ben Bolker



More information about the R-help mailing list