尝试在R中找到MLE时出现未知错误消息

时间:2018-09-26 08:11:00

标签: r mle

我正在尝试查找代码中将pdf指定为'mixture'的发行版的MLE。我提供了下面的错误代码 “在optim(start,f,method = method,hessian = TRUE,...)中出现错误:   L-BFGS-B需要有限值'fn'“

“声明”是im正在使用的数据集。我只使用“ claims”的前两个值尝试了相同的代码,并遇到了相同的问题,因此对于可重现的示例,前两个值是1536.77007和1946.92409。

分布参数的限制是0 <.p。<1且a> 0和b> 0,因此MLE函数的上下限。任何帮助深表感谢。

#create mixture of two exponential distribution
mixture<-function(x,p,a,b){
  d<-p*a*exp(-a*x)+(1-p)*b*exp(-b*x)
  d
  }


#find MLE of mixture distribution 
LL <- function(p,a,b) {
       X = mixture(claims,p,a,b)
      #
      -sum(log(X))
   }

mle(LL, start = list(p=0.5,a=1/100,b=1/100),method = "L-BFGS-B", lower=c(0,0,0), upper=c(1,Inf,Inf))

edit:不确定为什么要使用dput(),但是无论如何,

#first two values of claims put into dput() (the actual values are above)
dput(claims[1:2])
c(307522.103, 195633.5205)

0 个答案:

没有答案