0

I have this dataset which I know is from a beta distribution but with unknown parameters:

2.5% 0.264 50% 0.511 97.5% 0.759

Is there anyway to find the best-fit beta distribution and estimate the shape parameters by using r?

  • Short answer: Yes! It can be shown that two quantile values (under a natural ordering condition) uniquely determine a beta distribution's parameters `alpha` and `beta`. See for example [Do two quantiles of a beta distribution determine its parameters](https://stats.stackexchange.com/questions/235711/do-two-quantiles-of-a-beta-distribution-determine-its-parameters) and [Determining beta distribution parameters alpha and beta from two arbitrary points (quantiles)](https://stats.stackexchange.com/questions/112614/determining-beta-distribution-parameters-alpha-and-beta-from-two-arbitrary). [...] – Maurits Evers Jun 28 '18 at 22:01
  • [...] Hint: The last link contains an R implementation. – Maurits Evers Jun 28 '18 at 22:02

1 Answers1

0
m=function(z){
   if(any(z<0))return(NA)
   x=z[1];y=z[2]
   a=c(qbeta(0.025,x,y),qbeta(0.5,x,y),qbeta(0.975,x,y))-c(0.264,0.511,0.759)
   b=c(pbeta(0.264,x,y), pbeta(0.511,x,y), pbeta(0.759,x,y))-c(0.025,0.5,0.975)
   abs(a)+abs(b)
 }
sol=optim(c(0.1,1),function(x)sum(abs(m(x))),m)$par;sol
[1] 7.375020 7.071576
pbeta(0.264,sol[1],sol[2])
[1] 0.02500033# almost close to 0.025
 pbeta(0.511,sol[1],sol[2])
[1] 0.5
 pbeta(0.759,sol[1],sol[2])
[1] 0.9774994
 qbeta(0.025,sol[1],sol[2])
[1] 0.2639994
 qbeta(0.5,sol[1],sol[2])
[1] 0.511
 qbeta(0.975,sol[1],sol[2])
[1] 0.7542515

You can also decide to just use the pbeta alone or the qbeta alone, all this will give varied results but close to the correct results

Onyambu
  • 67,392
  • 3
  • 24
  • 53