[R] Simulating from a Weibull distribution

David Winsemius dwinsemius at comcast.net
Wed Sep 3 06:49:49 CEST 2014

On Sep 2, 2014, at 6:52 PM, Lucy Leigh wrote:

> Hi,
> I wish to simulate some data from a Weibull distribution. The rweibull function in R uses the parameterisation
> 'with shape parameter a and scale parameter b has density given by f(x) = (a/b) (x/b)^(a-1) exp(- (x/b)^a)'.
> However, it would be much more useful for me to simulate data using a different parameterisation of the
> Weibull, with shape a1 and scale b1,  namely f(x) = a1*b1*x^(a1-1)exp(-b1*x^a1).
> However I'm not sure how to do this, as I have only ever used the random generators that come pre-programmed in R.
> Is there a package or example someone can point me to that demonstrates how to simulate data from any given distribution?

You could look at an alternative parametrization in pkg:survival. An exmaple in the survreg docs says:

# Weibull parametrisation
y<-rweibull(1000, shape=2, scale=5)

survreg(Surv(y)~1, dist="weibull")
# survreg scale parameter maps to 1/shape, linear predictor to log(scale)

David Winsemius
Alameda, CA, USA

More information about the R-help mailing list