R中的帕累托分布拟合问题-结果/错误不一致

时间:2019-01-24 18:23:07

标签: r optimization error-handling

我试图将R中的pareto分布拟合,但遇到奇数错误。使用相同的数据框,我将收到以下结果:

1)它按预期工作,产生合理的结果 2)它不会引发任何错误,但是估计的参数等于初始的启动参数 3)

Error in optim(par = para_ini_pareto, fn = loglik_pareto, method = "Nelder-Mead",  : 
  non-finite finite-difference value [2]
In addition: There were 34 warnings (use warnings() to see them)

我的代码如下:

    loglik_pareto = function(param, x , L ){
 nloglik = -sum(log(dpareto(x, param[1], param[2])))+log(1- ppareto(L, param[1], param[2]))*length(x)*loglik_factor
  if(is.na(nloglik)) nloglik = .Machine$double.xmax
  return(nloglik)
}

在这种情况下,loglik_factor <- 1

配件本身是:

UoM_pareto_fit = optim(par = para_ini_pareto, fn = loglik_pareto, method =  "Nelder-Mead", 
                   x = UoM_Severity, L =trun_thshld, hessian = TRUE)

初始参数为 para_ini_pareto <- c(1, 1000)trunc_thshld <- 1000

我通常会清理环境并注销要用来重置所有内容的服务器,但似乎无法获得一致的结果。任何指导都将不胜感激。

0 个答案:

没有答案