dweibull producing NAN

Hello,

I am trying to estimate beta und k knowing that "duree" has a Weibull distribution, as follows:

duree = c(48.8, 7.3, 19.8, 68.4, 63.7, 42.9, 59.4, 25.7, 53.3, 27.3)

logV<- function(param, x)
{
  beta = param[1]
  k = param[2]
  liste = dweibull(x, shape = beta, scale =k, log = T)
  return (-sum(liste))
}

logV(param = c(1,1), x = duree)
solution = optim(c(1,1), logV, x = duree)

However, I get the following message :
NaNs produced in : dweibull(x, shape = beta, scale = k, log = T)

Can someone explain what is causing this warning please ?

if either param has value 0 then NaN would result. when optim tries different values, it can trigger that possibility.

 dweibull(duree, shape = 1, scale =1, log = T)
 [1] -48.8  -7.3 -19.8 -68.4 -63.7 -42.9 -59.4 -25.7 -53.3 -27.3
dweibull(duree, shape = 0, scale =1, log = T)
 [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

 dweibull(duree, shape = 1, scale =0, log = T)
 [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
1 Like

Thank you! I understand it now.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.