2

我不是 R 方面的专家,我正在尝试将热致死细菌数据拟合到 weibull 模型:

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

然后,我申请了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))

在那之后,在我看来错误

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

我确定这个错误与 start 中的 a 和 b 值有关。是否存在估计这些值的方法?

4

1 回答 1

2

如果N是每毫升的菌落形成单位数并且N0是时间 0 时的数字,那么您可能想要的是模型log(N/N0) ~ ...,而不是log(N) ~ ...因为log(N/N0) = log(N) - log(N0)我们有:

 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")

给予:

> 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

截屏

于 2015-12-06T15:59:55.243 回答