3

I am working on a project which involves combining two Weibull distributions and thus creating a double peaked curve. I then aim to make predictions using this. I have searched online and I can't seem to find anything on this or if R has a function that allows me to combine two Weibulls. Below shows the code I have used to create the two Weibull distributions I wish to combine to make one single probability density function.

curve(dweibull(x, scale=30.59898985, shape=2.27136646),from=0, to=70, main="Weibull distribution")
curve(dweibull(x, scale=19.39743639, shape=1.22800332),from=0, to=70, main="Weibull distribution")

Any help would be amazing.

Thanks!

IRTFM
  • 258,963
  • 21
  • 364
  • 487
Fiona
  • 477
  • 1
  • 9
  • 18

1 Answers1

3

Would it make sense to combine the probability distributions and then use the element "y" of your final list to make predictions? If so, this should work. The final AUC is still ~1.

dwb1 <- curve(dweibull(x, scale=30.59898985, shape=2.27136646),from=0, to=70, main="Weibull distribution")
dwb2 <- curve(dweibull(x, scale=19.39743639, shape=1.22800332),from=0, to=70, main="Weibull distribution")

# combine
final.dwb <- lapply(c("x", "y"), (function(i){
  (dwb1[[i]] + dwb2[[i]])/2
}))
names(final.dwb) <- c("x", "y")

# plot
plot(final.dwb$y ~ final.dwb$x, xlim=c(0,70), main = "combined Weibull distributions", type = "n", las = 2)
lines(final.dwb$y ~ final.dwb$x, xlim=c(0,70), main = "combined Weibull distributions")

Combined distribution plot

Say you want the probability at a time of interest

t1 = 30

Search among the x you have and find the closest to t1 and then return the corresponding y

id <- which.min(abs(t1 - final.dwb$x))
final.dwb$y[id]
Damiano Fantini
  • 1,925
  • 9
  • 11
  • I think he said it should be double peaked? – Hack-R Aug 15 '17 at 14:28
  • 2
    I understood the problem was not with the plotting... she has two probability distributions to merge into a single one to make predictions. Looking at the individual distributions suggests that their combination won't generate a double peaked distribution. – Damiano Fantini Aug 15 '17 at 14:31
  • OK but plotting aside, shouldn't it still be double peaked? If it's not then I'm not sure this is properly combining the distributions? – Hack-R Aug 15 '17 at 14:33
  • The individual peaks are too close to result in a double peaked distribution – Damiano Fantini Aug 15 '17 at 14:35
  • Ah that's great thanks! I don't understand how I can make predictions however. So say if I wanted to use the pdf to calculate the probability of a "failure" at time t (the x axis), how would I be able to use this combined Weibull to work out this probability? Is this what the function is doing? – Fiona Aug 15 '17 at 14:40
  • So, you want to know the probability of failure (y) at time t1 (x) for example? – Damiano Fantini Aug 15 '17 at 14:58
  • Yes, so at t1 (say x=30) what is the probability of failure? Sorry, I haven't done stats in ages so this is probably a basic question. – Fiona Aug 15 '17 at 15:00
  • 1
    I edited my answer to provide a very simple example. – Damiano Fantini Aug 15 '17 at 15:31
  • Amazing! Thank you so much for you help. Now I assume when trying to calculate the cdf of the function I will have to find new scale and shape values? – Fiona Aug 15 '17 at 15:41
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/151975/discussion-between-damiano-fantini-and-fiona). – Damiano Fantini Aug 15 '17 at 16:00