如何避免stat4包的mle函数中的-Inf对数似然问题?

时间:2019-03-13 12:19:55

标签: r dplyr statistics mle

我想最大化对数似然函数以适应某些数据,但是当对数似然为-Inf时,mle函数会因该错误而停止。

  

optim中的错误(start,f,method = method,hessian = TRUE,...):     L-BFGS-B需要有限的'fn'

代码是:

  ll <- function(shape, scale) {
  x <-
    c(2,  12,  61,   9,  25, 110,   7,  27,  17,  15,  11,  17,  15,  25,   0)
  - sum(dgamma(x, shape, scale, log = TRUE))
  }

    m <- stats4::mle(ll, start = list(shape = 2.15, scale = 2), method = "L-BFGS-B", lower = c(0.01, 0.01))

有人知道如何以干净的方式避免此问题吗?

0 个答案:

没有答案