Simulating from a Weibull distribution

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Simulating from a Weibull distribution

oxnard
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?

Cheers,

Lucy




        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Simulating from a Weibull distribution

Joshua Wiley-2
Hi Lucy,

Try the gamlss.dist package, specifically the rWEI2() function.

Cheers,

Josh


On Wed, Sep 3, 2014 at 11:52 AM, Lucy Leigh <[hidden email]>
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?
>
> Cheers,
>
> Lucy
>
>
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



--
Joshua F. Wiley
Ph.D. Student, UCLA Department of Psychology
http://joshuawiley.com/
Senior Analyst, Elkhart Group Ltd.
http://elkhartgroup.com
Office: 260.673.5518

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Simulating from a Weibull distribution

Duncan Murdoch-2
In reply to this post by oxnard
On 02/09/2014, 9: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?

That's the same distribution, just with the parameters specified
differently.  The correspondence is

a1 = a
b1 = b^(-a)

or

a = a1
b = b1^(-1/a1)

Duncan Murdoch

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Simulating from a Weibull distribution

oxnard
In reply to this post by Joshua Wiley-2
Awesome, thankyou!

From: Joshua Wiley [mailto:[hidden email]]
Sent: Wednesday, 3 September 2014 12:04 PM
To: Lucy Leigh
Cc: [hidden email]
Subject: Re: [R] Simulating from a Weibull distribution

Hi Lucy,

Try the gamlss.dist package, specifically the rWEI2() function.

Cheers,

Josh

On Wed, Sep 3, 2014 at 11:52 AM, Lucy Leigh <[hidden email]<mailto:[hidden email]>> 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?

Cheers,

Lucy




        [[alternative HTML version deleted]]

______________________________________________
[hidden email]<mailto:[hidden email]> mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
Joshua F. Wiley
Ph.D. Student, UCLA Department of Psychology
http://joshuawiley.com/
Senior Analyst, Elkhart Group Ltd.
http://elkhartgroup.com
Office: 260.673.5518

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Simulating from a Weibull distribution

David Winsemius
In reply to this post by oxnard

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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.