修改的Weibull错误-函数无法估计参数,错误代码为100

时间:2018-10-10 01:28:27

标签: r statistics distribution fitdistrplus

我试图估算Almalki和Yuan的修改后的Weibull分布(NMW)参数,但是遇到以下错误:

AIC的值仅是负数。出了点问题。我知道在文献中AIC可能为负值,但我认为估算或函数中存在一些错误。该bug可能在估算,fitdist之类的问题中吗?有人帮我吗?

文章

 https://www.sciencedirect.com/science/article/pii/S0951832012002396

累计功能

  pnmw = function(x, alpha, beta, gama,theta, lambda)
{
  1 - exp(-alpha*(x^(theta))-beta*(x^(gama))*exp(lambda*x))
}

密度函数

       dnmw = function(x, alpha, beta, gama, theta, lambda)
{
  (alpha * theta * (x^(theta - 1)) + beta*(((gama+lambda*x)*(x^(gama-1))*exp(lambda*x))*exp(-alpha*x^(theta)-beta*x^(gama)*exp(lambda*x)))) 
}

Harzard函数

   hnmw = function(x, alpha, beta, gama, theta, lambda)
{
  alpha * theta * x^(theta - 1) + beta * (gama  + lambda * x) * 
    x^(gama - 1) * exp(lambda * x)
}

生存功能

   snmw = function(x, alpha, beta, gama, theta, lambda)
{
  exp(-alpha*x^(theta)-beta*x^(gama)*exp(lambda*x))
}

估算

paramYuan = fitdist(data = dadosp, distr = 'nmw', start = c(0.05,5,1.25,5,0.05),lower = c(0, 0))

图像

 [https://i.stack.imgur.com/XDxwC.png][1] Image
    [https://i.stack.imgur.com/87Cid.png][1] Image Estimation
    [https://i.stack.imgur.com/FScsM.png][3] Image Functions

示例:

    dadosp = c(240.3,71.9,271.3, 186.3,241,253,287.4,138.3,206.9,176,270.4,73.3,118.9,203.1,139.7,31,269.6,140.2,205.1,133.2,107,354.6,277,27.6,186,260.9,350.4,242.6,292.5, 112.3,242.8,310.7,309.9,53.1,326.5,145.7,271.5, 117.5,264.7,243.9,182,136.7,103.8,188.3,236,419.8,338.6,357.7)

[https://i.stack.imgur.com/U0KwD.png][1]图像

1 个答案:

答案 0 :(得分:0)

让我们在密度函数上进行一些测试。

dnmw = function(x, alpha, beta, gama, theta, lambda)
   {
(alpha * theta * (x^(theta - 1)) + beta*(((gama+lambda*x)*(x^(gama-1))*exp(lambda*x))*
     exp(-alpha*x^(theta)-beta*x^(gama)*exp(lambda*x)))) 
    }
 curve(dnmw(x,4,.3,2.4,2,0.05))

enter image description here

我想我们需要得出一个结论,那就是这不是一个好的密度函数,因为它的整数显然大于1。还请参见文档:http://uksacb.org/sites/default/files/webform/Research%20Paper1_A%20new%20modi%EF%AC%81ed%20Weibull%20distribution_0.pdf

因此,将代码放入R-aware编辑器中,查看与最右边的括号匹配的位置:

dnmw = function(x, alpha, beta, gama, theta, lambda)
{
(alpha * theta * (x^(theta - 1)) + beta*(((gama+lambda*x)*(x^(gama-1))*exp(lambda*x))*
#^
             exp(-alpha*x^(theta)-beta*x^(gama)*exp(lambda*x)))) 
#                                                              ^
}

它与最左边的那个相匹配!但是,该左括号应该与exp(lambda*x)右边的那个相匹配,以消除我所谓的归一化术语。因此,在该位置放置一个正确的括号,并尝试找出其他地方缺少的括号。 ....经过更正后,我们得到:

dnmw = function(x, alpha, beta, gama, theta, lambda)
{
  (alpha*theta*(x^(theta - 1)) +beta*( (gama+lambda*x) * x^(gama-1)*
  exp(lambda*x) ))*exp(-alpha*x^(theta)-beta*x^(gama)*exp(lambda*x))
}

enter image description here

现在,在检查图形测试时,事情看起来更加明智。但是我也认为您需要确保其他分布函数没有类似的错误。