How to find parameter of function using MLE method?

조회 수: 9 (최근 30일)
Mary Jacketti
Mary Jacketti 2019년 5월 6일
댓글: Jeff Miller 2019년 5월 7일
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?

답변 (1개)

Jeff Miller
Jeff Miller 2019년 5월 7일
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
Mary Jacketti
Mary Jacketti 2019년 5월 7일
Is there any way to get around that? Like calling the function differently or including it in Llikef?
Jeff Miller
Jeff Miller 2019년 5월 7일
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?

댓글을 달려면 로그인하십시오.

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by