Cannot use MLE for custom distribution with right censored data
8 次查看(过去 30 天)
显示 更早的评论
I have been trying to use the MLE function in Matlab to compute the parameters of a custom Weibull distribution, but I'm always getting errors such as my custom probability function returns negative or zero values. I have tried multiple variations of my approach, and finally gave up before asking for help here. The custom Weibull distribution is a 2-parameter one (just like https://se.mathworks.com/help/stats/weibull-distribution.html), with the exception that the scale parameter is a function of voltage and temperature:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1628973/image.png)
The voltage and temperature are input variables that I provide to my code, and therefore what I want from MLE is to return 4 parameters: C, n, B (from the scale parameter function), and the b shape parameter.
The following is my code. I've added both the PDF and CDF as described in (https://se.mathworks.com/help/stats/mle.html). The failureTimes variable is self-explanatory, and category refers to actual (0) or right-censored (1) data.
I'll appreciate so much if anyone can help me here.
Thanks a lot in advance.
% constants
kB = 1.380649e-23; % [J/K]
q = 1.60217663e-19; % [C]
V = 50.0;
T = 125.0 + 273.15;
failureTimes = [238.1 916.5 935.7 991.0 1286.6 1372.3 1457.8 1521.0 1662.0 1710.0 1760.0 1797.0 1812.0 1818.0 1835.0 1850.0 ...
1863.0 1876.0 1890.0 1942.0 1997.0 2035.0 2086.0 2155.0 2198.0 2254.0 2297.0 2365.0 2401.0 2469.0 2524.0 2567.0 2609.0 ...
2689.0 2700.0 2705.0 2821.0 2878.0 2914.0 2990.0 3045.0 3098.0 3148.0 3199.0 3254.0 3300.0 3346.0 3407.0 3441.0 3451.0 ...
3506.5 3559.0 3602.0 3657.0 3706.0 3745.0 3799.0 3854.0 3867.0 3956.0 3957.0 3957.0 3957.0 3957.0 3957.0 3957.0 3957.0 ...
3957.0 3957.0 3957.0 3957.0 3957.0 3957.0 3957.0 3957.0 3957.0 3957.0 3957.0 3957.0 3957.0];
category = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1];
capsWeibull_pdf = @(data,c,n,B,b) ((V.^n)*exp(-B/T).*b/c)*((V.^n)*exp(-B/T).*data/c).^(b-1).*exp(-((V.^n)*exp(-B/T).*data/c).^b);
capsWeibull_cdf = @(data,c,n,B,b) 1 - exp(-((V.^n).*exp(-B/T).*data/c).^b);
phat = mle(failureTimes,'pdf',capsWeibull_pdf,'cdf',capsWeibull_cdf,'Start',[5,3,q*1.9/kB,3.5],'Censoring',category);
0 个评论
回答(1 个)
Sai Pavan
2024-3-25
Hello Leonardo,
I understand that you are trying to resolve the "Custom probability function returned negative or zero values" error when trying to compute the parameters of a custom Weibull distribution with "mle" function.
It can be observed that the initial parameter values given as input to the "mle" function with the "Start" argument are slightly higher for the custom pdf and cdf functions, especially the third value in the row vector. This error can be resolved by changing the initial parameter values to smaller values such as [0.1,0.1,0.1,0.1] with the "Start" argument.
Please refer to the following documentation to learn more about the "Start" argument of "mle" function: https://www.mathworks.com/help/stats/mle.html#:~:text=Start%20%E2%80%94%20Initial%20parameter%20values
Hope it helps!
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!