How to fit a random data into Beta distribution?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How to fit a random data into Beta distribution?

Shekhar-2
Hi,
I have some random data and i want to find out the parameters of Beta
distribution ( a and b) such that this data approximately fits into
this distribution. I have tried by plot the histograms and graph, but
it requires lot of tuning and i am unable to do that. can anyone tell
me how to do it programmitically in R?

Regards,
Som Shekhar

______________________________________________
[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: How to fit a random data into Beta distribution?

Steven Kennedy-2
library(MASS)
fitdistr(x,"beta",list(shape1=1,shape2=1))



On Tue, May 3, 2011 at 9:44 PM, Shekhar <[hidden email]> wrote:

>
> Hi,
> I have some random data and i want to find out the parameters of Beta
> distribution ( a and b) such that this data approximately fits into
> this distribution. I have tried by plot the histograms and graph, but
> it requires lot of tuning and i am unable to do that. can anyone tell
> me how to do it programmitically in R?
>
> Regards,
> Som Shekhar
>
> ______________________________________________
> [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.

______________________________________________
[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: How to fit a random data into Beta distribution?

Shekhar-2
Hi Steven,
Thanks for the quick reply. i have tried but
its giving me error--->Error in optim(x = c(38.1815173696765,
-12.7988197976440, -3.88212459045077,  :
  initial value in 'vmmin' is not finite


i have tried something like this:

library(MASS)
x<-rnorm(n=100,mean=10,sd=20);
fitdistr(x,dbeta,start=list(shape1=1,shape2=1)

Please correct me if my understanding is wrong:
In the fitdistr fucntion we are providing the initial values of the
Beta distribution parameters as shape1=1 and shape2=1. This function
will try to fit the data and give us the new parameters of Beta
distribution that approximately fits this data.


I have tried the function with other distribution like Normal, Gamma,
Weibull...its working fine..

Regards,
Som Shekhar




On May 4, 1:25 am, Steven Kennedy <[hidden email]> wrote:

> library(MASS)
> fitdistr(x,"beta",list(shape1=1,shape2=1))
>
>
>
> On Tue, May 3, 2011 at 9:44 PM, Shekhar <[hidden email]> wrote:
>
> > Hi,
> > I have some random data and i want to find out the parameters of Beta
> > distribution ( a and b) such that this data approximately fits into
> > this distribution. I have tried by plot the histograms and graph, but
> > it requires lot of tuning and i am unable to do that. can anyone tell
> > me how to do it programmitically in R?
>
> > Regards,
> > Som Shekhar
>
> > ______________________________________________
> > [hidden email] mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> [hidden email] mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[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: How to fit a random data into Beta distribution?

Steven Kennedy-2
Hi Shekhar,

It looks from your error that you have values outside the range 0 to
1. The beta distribution is only defined between 0 and 1. Can you
please post your data set (or at least a portion of it)?




On Wed, May 4, 2011 at 3:24 PM, Shekhar <[hidden email]> wrote:

> Hi Steven,
> Thanks for the quick reply. i have tried but
> its giving me error--->Error in optim(x = c(38.1815173696765,
> -12.7988197976440, -3.88212459045077,  :
>  initial value in 'vmmin' is not finite
>
>
> i have tried something like this:
>
> library(MASS)
> x<-rnorm(n=100,mean=10,sd=20);
> fitdistr(x,dbeta,start=list(shape1=1,shape2=1)
>
> Please correct me if my understanding is wrong:
> In the fitdistr fucntion we are providing the initial values of the
> Beta distribution parameters as shape1=1 and shape2=1. This function
> will try to fit the data and give us the new parameters of Beta
> distribution that approximately fits this data.
>
>
> I have tried the function with other distribution like Normal, Gamma,
> Weibull...its working fine..
>
> Regards,
> Som Shekhar
>
>
>
>
> On May 4, 1:25 am, Steven Kennedy <[hidden email]> wrote:
>> library(MASS)
>> fitdistr(x,"beta",list(shape1=1,shape2=1))
>>
>>
>>
>> On Tue, May 3, 2011 at 9:44 PM, Shekhar <[hidden email]> wrote:
>>
>> > Hi,
>> > I have some random data and i want to find out the parameters of Beta
>> > distribution ( a and b) such that this data approximately fits into
>> > this distribution. I have tried by plot the histograms and graph, but
>> > it requires lot of tuning and i am unable to do that. can anyone tell
>> > me how to do it programmitically in R?
>>
>> > Regards,
>> > Som Shekhar
>>
>> > ______________________________________________
>> > [hidden email] mailing list
>> >https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>> ______________________________________________
>> [hidden email] mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> [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.
>

______________________________________________
[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.
Ali
Reply | Threaded
Open this post in threaded view
|

Re: How to fit a random data into Beta distribution?

Ali

Dear Shekar,
For me I had such a problem, when I repeated with many dist. So, I drafted my own procedure for example for Weibull, Gamma and Log-Normal without any warnings. But you can ignore the Warning, since the result was somehow the same for my case.
Regards,
Ali

> Date: Wed, 4 May 2011 19:46:54 +1000
> From: [hidden email]
> To: [hidden email]
> CC: [hidden email]
> Subject: Re: [R] How to fit a random data into Beta distribution?
>
> Hi Shekhar,
>
> It looks from your error that you have values outside the range 0 to
> 1. The beta distribution is only defined between 0 and 1. Can you
> please post your data set (or at least a portion of it)?
>
>
>
>
> On Wed, May 4, 2011 at 3:24 PM, Shekhar <[hidden email]> wrote:
> > Hi Steven,
> > Thanks for the quick reply. i have tried but
> > its giving me error--->Error in optim(x = c(38.1815173696765,
> > -12.7988197976440, -3.88212459045077,  :
> >  initial value in 'vmmin' is not finite
> >
> >
> > i have tried something like this:
> >
> > library(MASS)
> > x<-rnorm(n=100,mean=10,sd=20);
> > fitdistr(x,dbeta,start=list(shape1=1,shape2=1)
> >
> > Please correct me if my understanding is wrong:
> > In the fitdistr fucntion we are providing the initial values of the
> > Beta distribution parameters as shape1=1 and shape2=1. This function
> > will try to fit the data and give us the new parameters of Beta
> > distribution that approximately fits this data.
> >
> >
> > I have tried the function with other distribution like Normal, Gamma,
> > Weibull...its working fine..
> >
> > Regards,
> > Som Shekhar
> >
> >
> >
> >
> > On May 4, 1:25 am, Steven Kennedy <[hidden email]> wrote:
> >> library(MASS)
> >> fitdistr(x,"beta",list(shape1=1,shape2=1))
> >>
> >>
> >>
> >> On Tue, May 3, 2011 at 9:44 PM, Shekhar <[hidden email]> wrote:
> >>
> >> > Hi,
> >> > I have some random data and i want to find out the parameters of Beta
> >> > distribution ( a and b) such that this data approximately fits into
> >> > this distribution. I have tried by plot the histograms and graph, but
> >> > it requires lot of tuning and i am unable to do that. can anyone tell
> >> > me how to do it programmitically in R?
> >>
> >> > Regards,
> >> > Som Shekhar
> >>
> >> > ______________________________________________
> >> > [hidden email] mailing list
> >> >https://stat.ethz.ch/mailman/listinfo/r-help
> >> > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> >> > and provide commented, minimal, self-contained, reproducible code.
> >>
> >> ______________________________________________
> >> [hidden email] mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
> > ______________________________________________
> > [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.
> >
>
> ______________________________________________
> [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.
     
        [[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: How to fit a random data into Beta distribution?

Shekhar-2

Hi,

@Steven: Since Beta distribution is a generic distribution by which i
mean that by varying the parameter of alpha and beta we can fit any
distribution.
So to check this i generated a random data from Normal distribution
like

x.norm<-rnorm(n=100,mean=10,sd=10);

Now i want to estimate the paramters alpha and beta of the beta
distribution which will fit the above generated random data. That's
what i want to do.

@Ali: When you said you drafted your own procedure, do you mean that
you are calculate the parameters using MLE or bayesian..???Can you
please give me some more ideas into this?

Thanks and Regards,
Som Shekhar

______________________________________________
[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: How to fit a random data into Beta distribution?

Ravi Varadhan
Beta is not as general as you think.  Its support is limited to [0,1], but you are trying to fit data that lies outside of its support.  Please read about the beta distribution from a basic stats/prob book.  

Ravi.
________________________________________
From: [hidden email] [[hidden email]] On Behalf Of Shekhar [[hidden email]]
Sent: Thursday, May 05, 2011 6:54 AM
To: [hidden email]
Subject: Re: [R] How to fit a random data into Beta distribution?

Hi,

@Steven: Since Beta distribution is a generic distribution by which i
mean that by varying the parameter of alpha and beta we can fit any
distribution.
So to check this i generated a random data from Normal distribution
like

x.norm<-rnorm(n=100,mean=10,sd=10);

Now i want to estimate the paramters alpha and beta of the beta
distribution which will fit the above generated random data. That's
what i want to do.

@Ali: When you said you drafted your own procedure, do you mean that
you are calculate the parameters using MLE or bayesian..???Can you
please give me some more ideas into this?

Thanks and Regards,
Som Shekhar

______________________________________________
[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.
______________________________________________
[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: How to fit a random data into Beta distribution?

MikeK
I am also trying to fit data to a beta distribution.

In Ang and Tang, Probability Concepts in Engineering, 2nd Ed., page 127-9, they describe a variant of a beta distribution with additional parameters than the standard beta distribution, enabling specification of a max and min value other than 0,1. This would be very useful for my purposes.

Any thoughts on how to fit a distribution directly to this variant of the beta distribution, without starting from scratch?
Reply | Threaded
Open this post in threaded view
|

Re: How to fit a random data into Beta distribution?

David Winsemius

On May 11, 2011, at 11:17 PM, MikeK wrote:

> I am also trying to fit data to a beta distribution.
>
> In Ang and Tang, Probability Concepts in Engineering, 2nd Ed., page  
> 127-9,
> they describe a variant of a beta distribution with additional  
> parameters
> than the standard beta distribution, enabling specification of a max  
> and min
> value other than 0,1. This would be very useful for my purposes.
>
> Any thoughts on how to fit a distribution directly to this variant  
> of the
> beta distribution, without starting from scratch?
>

Scale your data to [0,1], fit, predict, invert the scaling.

xscaled <- (x-min(x))/max(x)
....
xrescaled <- max(x)*xscaled + min(x)

(Better check that I made the correct order of those operations. The  
first attempt was wrong ... I think.)

--
David Winsemius, MD
West Hartford, CT

______________________________________________
[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.