How to find parameter of function using MLE method?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a distribution that I am trying fit to data to find the parameters using the MLE method. However, I am stuck in my code. Below is the code:
%initial guess
phat0 = [0.1 0.5];
%distribution I am trying to fit to data
DGDpdf = @(phat) ((phat(1)).^(z(jjj,:).^phat(2)))-((phat(1)).^((z(jjj,:)+1).^phat(2)));
%MLE method
%phat(1) and phat(2) are the parameters of the distribution
%z(jjj,:) is the data
Llikef = @(phat)-sum(log(DGDpdf(max(min(phat(1),0.9999999),0.0000001),max(phat(2),0.0000001),z(jjj,:))));
[phat,Llikef] = fminsearch(Llikef,phat0);
q=max(min(phat(1),0.9999999),0.0000001)
N=max(phat(2),0.0000001)
When I try to find the parameters, this code gives me an error:
Error using DGDpdf>@(phat)((phat(1)).^(z(jjj,:).^phat(2)))-((phat(1)).^((z(jjj,:)+1).^phat(2)))
Too many input arguments.
I have also tried just putting the DGDpdf function into the Llikef function, but that gives an error as well.
Anyone have any suggestions on how to find the parameters of the distribution?
0 commentaires
Réponses (1)
Jeff Miller
le 7 Mai 2019
It looks like you have defined DGDpdf as having a single argument, the vector phat. But when you call DGDpdf within Llikef, you are passing 3 different arguments to it: max(), max(), z(). MATLAB doesn't know how to cope with the extra two arguments.
2 commentaires
Jeff Miller
le 7 Mai 2019
Well there is surely a way, but it's not entirely clear to me what you are trying to do. I suspect you want Llikef to call DGDpdf with the phat as a vector more like this (note [])
Llikef = xxx DGDpdf([max(min(phat(1),0.9999999),0.0000001),max(phat(2),0.0000001)])
Not exactly clear how to deal with z(jjj,:). Is it defined within the same scope as DGDpdf. If so, then Llikef doesn't need to pass it?
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!