使用 MLE 函数估计自定义分布的参数

Using MLE function to estimate the parameters of a custom distribution

我正在尝试使用 MATLAB 中的 mle() 函数来估计 6 参数自定义分布的参数。

自定义分布的PDF

并且 CDF

其中 Γ(x,y) 和 Γ(x) 是 上不完全伽马函数gamma 函数 α, θ, β, a, bc是自定义分布的参数。 K

给出

给定一个数据向量'data',我想估计参数α, θ, β、a、b 和 c.

到目前为止,我已经想出了这个代码:

data        =  rand(20000,1); % Since I cannot upload the acutal data, we may use this
t           =  0:0.0001:0.5;    
fun         =  @(w,a,b,c) w^(a-1)*(1-w)^(b-1)*exp^(-c*w);

% to estimate the parameters
custpdf     =  @(data,myalpha,mybeta,mytheta,a,b,c)...
                ((integral(@(t)fun(t,a,b,c),0,1)^-1)*...
                mybeta*...
                igamma(myalpha,((mytheta/t)^mybeta)^(a-1))*...
                (mytheta/t)^(myalpha*mybeta+1)*...
                exp(-(mytheta/t)^mybeta-(c*(igamma(myalpha,(mytheta/t)^mybeta)/gamma(myalpha)))))...
                /...
                (mytheta*...
                gamma(myalpha)^(a+b-1)*...
                (gamma(myalpha)-igamma(myalpha,(mytheta/t)^mybeta))^(1-b));

custcdf     =  @(data,myalpha,mybeta,mytheta,a,b,c)...
                (integral(@(t)fun(t,a,b,c),0,1)^-1)*...
                integral(@(t)fun(t,a,b,c),0,igamma(myalpha,(mytheta/t)^mybeta)^mybeta/gamma(myalpha));

phat        =  mle(data,'pdf',custpdf,'cdf',custcdf,'start',0.0);

但我收到以下错误:

Error using mlecustom (line 166)
Error evaluating the user-supplied pdf function
'@(data,myalpha,mybeta,mytheta,a,b,c)((integral(@(t)fun(t,a,b,c),0,1)^-1)*mybeta*igamma(myalpha,((mytheta/t)^mybeta)^(a-1))*(mytheta/t)^(myalpha*mybeta+1)*exp(-(mytheta/t)^mybeta-(c*(igamma(myalpha,(mytheta/t)^mybeta)/gamma(myalpha)))))/(mytheta*gamma(myalpha)^(a+b-1)*(gamma(myalpha)-igamma(myalpha,(mytheta/t)^mybeta))^(1-b))'.

Error in mle (line 245)
            phat = mlecustom(data,varargin{:});

Caused by:
    Not enough input arguments.

我试图查看错误行,但我无法找出错误的实际位置。

哪个函数缺少的输入较少?是指fun吗?为什么 mle 在尝试估计参数时缺少更少的输入?

有人可以帮我调试错误吗?

提前致谢。

  • exp()是一个函数,不是变量,精确到参数
exp^(-c*w) ---> exp(-c*w)
  • 起点关注6 parameters,不止一个 0.1*ones(1,6)
  • 在custcdf中mle要求积分的上限为a 标量,我做了一些试验和错误,范围是 [2~9]。为了 尝试一些值导致负 cdf 或小于 1 丢弃它们。
  • 然后用右边的计算上界看看是不是 与您预定义的相同。

我re-write所有的功能,看看

代码如下

Censored = ones(5,1);% All data could be trusted 

data        =  rand(5,1); % Since I cannot upload the acutal data, we may use this

f         =  @(w,a,b,c) (w.^(a-1)).*((1-w).^(b-1)).*exp(-c.*w);
% to estimate the parameters
custpdf     =  @(t,alpha,theta,beta, a,b,c)...
                (((integral(@(w)f(w,a,b,c), 0,1)).^-1).*...
                beta.*...
                ((igamma(alpha, (theta./t).^beta)).^(a-1)).*...
                ((theta./t).^(alpha.*beta + 1 )).*...
                exp(-(((theta./t).^beta)+...
                c.*igamma(alpha, (theta./t).^beta)./gamma(alpha))))./...
                (theta.*...
                ((gamma(alpha)).^(a+b-1)).*...
                 ((gamma(alpha)-...
                 igamma(alpha, (theta./t).^beta)).^(1-b)));


custcdf = @(t,alpha,theta,beta, a,b,c)...
         ((integral(@(w)f(w,a,b,c), 0,1)).^-1).*...         
     (integral(@(w)f(w,a,b,c), 0,2));



phat = mle(data,'pdf',custpdf,'cdf',custcdf,'start', 0.1.*ones(1,6),'Censoring',Censored);

结果

    phat = 0.1017    0.1223    0.1153    0.1493   -0.0377    0.0902