使用MLE函数估计自定义分布的参数 [英] Using MLE function to estimate the parameters of a custom distribution

查看:814
本文介绍了使用MLE函数估计自定义分布的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to use mle() function in MATLAB to estimate the parameters of a 6-parameter custom distribution.

自定义分发的 PDF

CDF

其中Γ (x,y)和Γ (x)是上部不完全伽玛函数 gamma功能. α θ β a b c 是自定义分发的参数. K

where Γ(x,y) and Γ(x) are the upper incomplete gamma function and the gamma function, respectively. α, θ, β, a, b, and c are the parameters of the custom distribution. K is given by

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

Given a data vector 'data', I want to estimate the parameters α, θ, β, a, b, and c.

到目前为止,我已经提出了以下代码:

So, far I have come up with this code:

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.

我试图调查错误行,但我无法弄清楚错误的实际出处.

I tried to look into the error lines but I can't figure out where the error actually is.

哪个功能缺少输入?它是指fun吗?为什么mle尝试估算参数时会缺少较少的输入?

Which function lacks fewer inputs? Is it referring to fun? Why would mle lack fewer inputs when it is trying to estimate the parameters?

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

Could someone kindly help me debug the error?

谢谢.

推荐答案

  • exp()是一个函数,而不是变量,精确说明了参数
    • exp() is a function, not a variable, precise the argument
    • exp^(-c*w) ---> exp(-c*w)
      

      • 起点与6 parameters有关,而不仅仅是一个 0.1*ones(1,6)
      • 在custcdf中,mle要求积分的上限为 标量,我做了一些试验和错误,范围是[2~9].为了 试用某些值会导致cdf为负值或小于1则将其丢弃.
      • 然后使用合适的一个计算上限,看看是否是 与您预定义的相同.
        • The starting point concerns the 6 parameters, not only one 0.1*ones(1,6)
        • In custcdf mle requires the upper bound of the integral to be a scalar, I did some trial and error and the range is [2~9]. for the trial some values lead to negative cdf or less than 1 discard them.
        • Then use the right one to compute the upper bound see if it's the same as the one you predefined.
        • 我重新编写了所有功能,将其签出

          I re-write all the functions, check them out

          代码如下

          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
          

          这篇关于使用MLE函数估计自定义分布的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆