n p
 
> I want to simulate data (time to failure) from a
> Weibull distribution:
> 
> p.d.f. :
> f(t)=lamda*gamma*t^(gamma-1)*exp(-lamda*t^gamma)
> 
> (scale = lamda, shape=gamma)
> 
> I have downloaded the "rnd" package (through "findit")
> and using the "rndwei" command I get the following
> puzzling (at least for me) results:
> 
> 
> . drop _all
> 
> . rndwei 10000 1.5 0.0078
> ( Generating . )
> Variable xw created.
> 
> . gen ev=1
> 
> . stset xw ev
> 
>      failure event:  ev ~= 0 & ev ~= .
> obs. time interval:  (0, xw]
>  exit on or before:  failure
> 
> 
> . streg ,dist(wei) nohr nolog
> 
>          failure _d:  ev
>    analysis time _t:  xw
> --------------------------
>  _cons |   -7.35076   
>      p |   1.513405  
> --------------------------
> 
> 1.513405 very close to 1.5 
> 
> but
> 
> . di exp(-7.35076)
> .0006421
> 
> and
> 
> . di exp(-7.35076/1.513405)
> .00777299
> 
> If I use the AFT form in streg, the exponentiated
> coefficient of the constant gives the correct result.
> 
> I think this has to do with the parametrization used
> in "rndwei" but the help for this command is very
> limited. Do you think that rndwei is using some
> parametrization like lamda=(lamda')^gamma or am I
> missing something? I think that I have seen this
> parametrization among sociologists texts but my
> background is biostatistical (I was trying to
> replicate some examples from D. Collet's survival
> book)
> 
> I would appreciate any other ideas for a Weibull
> simulation or even better a Weibull with frailties
> simulation.
When all else fails, look at the code. 
For shape parameter gamma and scale parameter lambda, -rndwei- 
boils down to one expression 
((log(1/uniform()))^(1/ gamma)) / lambda
where naturally you need to plug in numbers instead 
of parameter names. 
That's got lambda as the reciprocal of the way 
it is parameterised in two texts I looked at, 
after which I stopped looking. As you say, 
there are different parameterisations in 
different literatures. 
However, your own pdf looks wrong on 
a casual glance, if only on dimensional grounds. 
But for a two-parameter Weibull, random 
number generation is just one line, and 
you need not depend on anybody's program
once you know your own parameterisation. 
Nick 
[email protected] 
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/