1

I would like to simulate data set which has a decreasing and then increasing hazard from 3 weibull distributions but I would like to have this hazard function more near to zerohow can I get around 0.1 or less. How can I fix my code to have this?

B--rian
  • 5,578
  • 10
  • 38
  • 89
rose
  • 1,971
  • 7
  • 26
  • 32

1 Answers1

2

It's not necessary to use pexp and rexp, because the Exponential is a degenerate case of the Weibull distribution when the shape parameter=1. Shapes less than 1 are going to be even more "scoopy" near the origin. You could get a nice bathtubwith just two Weibull, but since you had one with three, I just made some minor alterations:

 hazmix = function(w1, w2, x) {w1*dweibull(x,.8, 1)/(1-pweibull(x, .8, 1))+ 
    + w2*dweibull(x,1,.5) + 
    ((1-(w1+w2))* dweibull(x, 6, 10)/(1-pweibull(x, 6, 10)))}

 png();plot(hazmix(.2,.4, seq(0, 10, by=.1)), ylim=c(0,1) ); dev.off()

enter image description here

I don't promise that it's normalized and if you needed a normalized distribution it would be much easier to just use two Weibulls with one mixing parameter.

IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • Thanks for you reply. How can I modify my code for two Weibull components to have a normalized distribution? – rose Jun 08 '14 at 03:37
  • I don't know about your code, but if you have two pdfs, by the additivity of integrals you can just multiply one by a fraction, c, less than 1 and the other by a fraction (1-c) so the integral of the sum will be 1. – IRTFM Jun 08 '14 at 04:51