2

I'm not an expert in R, and I'm trying to fit thermal-death bacteria data to a weibull model:

log._CFU.ml=c(9.6,9.2,9,8.5,9,7.5,6.8,5.8)
time_min=c(0,10,15,20,25,30,35,45)
ecoli_52=data.frame(log._CFU.ml,time_min)
weibull=function(x,a,b){-(1/2.303)*((x/a)^b)} #first i defined the function

Then, I applied nls:

mod.ecoli_52=nls(ecoli_52$log._CFU.ml~weibull(ecoli_52$time_min,a,b),
                 ecoli_52,start=list(a=1,b=1))

After that, it appeared to me the error

Error in numericDeriv(form[[3L]], names(ind), env) : 
  Missing value or an infinity produced when evaluating the model

I'm sure that this error is about the a and b values in start. Does a method exist to estimate these values?

B--rian
  • 5,578
  • 10
  • 38
  • 89

1 Answers1

2

If N is the number of colony forming units per ml and N0 is the number at time 0 then you may have intended the model log(N/N0) ~ ... rather than log(N) ~ ... and since log(N/N0) = log(N) - log(N0) we have:

 log_ratio <- with(ecoli_52, log._CFU.ml - log._CFU.ml[1])
 fm <- nls(log_ratio ~ weibull(time_min, a, b), ecoli_52, start = list(a = 1, b = 1))

 plot(log_ratio ~ time_min, ecoli_52)
 lines(fitted(fm) ~ time_min, ecoli_52, col = "red")

giving:

> fm
Nonlinear regression model
  model: log_ratio ~ weibull(time_min, a, b)
   data: ecoli_52
     a      b 
13.314  1.804 
 residual sum-of-squares: 0.7894

Number of iterations to convergence: 7 
Achieved convergence tolerance: 6.363e-07

screenshot

G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341