[R] Beta distribution- help needed
(Ted Harding)
ted.harding at wlandres.net
Tue Jul 26 16:42:37 CEST 2011
On a point of information, the beta distribution is indeed
defined for x >= 0 and, respectively, for x <= 1 so long as
the parameters a="shape1" and b="shape2" are respectively
not less than 1:
dbeta(x,a,b) = (x^(a-1))*((1-x)^(b-1))/Beta(a,b)
When a=1 and b=1 we have the uniform distribution on [0,1]
which certainly allows x=0 or x=1.
If a<1 then the density --> Inf as x --> 0.
If b<1 then the density --> Inf as x --> 1.
In these cases the density does not have a finite value
for x=0 respectively x=1. For a >=1 and b >= 1, the density
is finite at x=0 and at x=1, so either is a legitimate value.
The help info '?dbeta' says:
The Beta distribution with parameters 'shape1' = a and
?shape2' = b has density
Gamma(a+b)/(Gamma(a)Gamma(b))x^(a-1)(1-x)^(b-1)
for a > 0, b > 0 and 0 <= x <= 1 where the boundary values
at x=0 or x=1 are defined as by continuity (as limits).
So R itself has no problem with x=0 or x=1 when the density
makes sense mathematically. Indeed, it also gives the expected
results when a<1 and/or b<1:
dbeta(0,0.5,0.5)
# [1] Inf
I don't know how fitdist() works: maybe it automatically
rejects x=0 and x=1 whatever the values of a and b if < 1.
Possibly, however, in baxy77's example fitdist() was trying
to use values of a or b which are less that 1, and fitdist
threw an error because of the infinity.
Hoping this helps,
Ted.
On 26-Jul-11 13:12:36, Daniel Malter wrote:
> This is not very confusing. It is the exact same error in
> the sense that this time the values of x1 are not only
> outside the interval (0-1) but within [0-1] as in your
> first example, but this time they are also outside [0-1].
> The reason is that you did not divide x1 by sum(x1) this
> time. In other words, the problem that the values you
> supply to fitdist() are not permissible by the definition
> of the distribution "got even worse" if one may say so.
> For fitdist() to estimate the parameters of a beta
> distribution it needs the values to be in the open interval (0-1).
>
> Read up on http://en.wikipedia.org/wiki/Beta_distribution
> where the first sentence says: "In probability theory and
> statistics, the beta distribution is a family of continuous
> probability distributions defined on the interval (0, 1)..."
>
> HTH,
> Daniel
>
>
> baxy77 wrote:
>>
>> ok then this is confusing
>>
>> if i do it like this:
>>
>> x1 <- c(100,200,140,98,97,56,42,10,2,2,1,4,3,2,12,3,1,1,1,1,0,0);
>> k <-fitdist(x1, "beta")
>> plot(k)
>>
>> it says
>>
>>
>> Error in mledist(data, distname, start, fix.arg, ...) :
>> values must be in [0-1] to fit a beta distribution
>> Calls: fitdist -> mledist
>>
>>
>> I mean the real problem is the Cullen-Frey plot says it is a beta
>> distribution and i want to see its function . how do i do this
>>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Beta-distribution-help-needed-tp3695076p36
> 95639.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org 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.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 26-Jul-11 Time: 15:42:33
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list