How do I estimate the parameters for a beta distribution using MLE?
Show older comments
I have tried to search and I have tried out several things in Matlab and I cannot figure out for the life of me what is going on. :(
If I take an example dataset:
alpha = 1.5 ; beta = 1.25 ;
x = 0:0.01:1 ;
y = betapdf(x,alpha,beta) ;
Then, I want to estimate the alpha and beta parameters from this distribution, how do I do it?
I'll show you what I've tried and what hasn't worked...
Attempt 1:
>> phat = mle(y,'distribution','beta')
Error using betafit (line 45)
All values must be within the closed interval [0,1].
Error in mle (line 278)
phat = betafit(data,alpha);
Attempt 2:
>> phat = betafit(y,0.1) ;
Error using betafit (line 45)
All values must be within the closed interval [0,1].
Attempt 3:
>> phat = mle(y*0.01,'distribution','beta')
ans =
0.112285261232716 11.744190900225709
Attempt 4:
>> phat = betafit(y*0.01,0.1)
ans =
0.112285261232716 11.744190900225709
Attempt 5:
alphas = 0.1:0.1:4 ; betas = alphas ;
lnlik = zeros(length(alphas),length(betas)) ;
for i = 1:length(alphas)
for j = 1:length(betas)
lnlik(i,j) = betalike([alphas(i) betas(j)],y*0.01) ;
end
end
[ind(:,1),ind(:,2)] = find(lnlik == min(min(lnlik))) ;
>> [alphas(ind(1)), betas(ind(2))
ans =
0.100000000000000 4.000000000000000
Grrr! How do I do this?? I have some data that I want to find the best-fitting beta distribution, but I cannot even figure it out for a distribution I know is beta…please help me! What am I doing wrong???
The examples I've seen for using these estimation functions all use betarnd as the function to generate the sample, but I when I plot the results from betarnd, I cannot make sense of it. I am so utterly confused as to what betarnd is really (I tried a comparison with normrnd to see if I could understand, I was just as much at a loss…the results do not look like a normal distribution). I'm so confused.
Accepted Answer
More Answers (0)
Categories
Find more on Beta Distribution in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!