Matrix dimensions must agree

Hello,
So, I've tested this program with many other distributions and it worked. However, when I changed the probability density function 'custpdf' in the code below, I got
an error saying tha matrix dimentsions must agree.
x=xlsread('my_data.xlsx');
t=x(:,1);
cens=x(:,2);
x1=x(:,3);
x2=x(:,4);
custpdf = @(t,alpha,beta,b0,b1,b2)exp(b0+b1.*x1+b2.*x2).*(exp((alpha./-beta).*(exp(beta.*...
t)-1))).^(exp(b0+b1.*x1+b2.*x2)-1).*alpha.*exp(beta.*t).*exp(-(alpha.*...
(exp(beta.*t)-1))./beta);
custcdf = @(t,alpha,beta,b0,b1,b2) 1-(exp((alpha/-beta).*(exp(beta.*t)-1))).^exp(b0+b1.*...
x1+b2.*x2);
[phat,pci] = mle(t,'pdf',custpdf,'cdf',custcdf,'start',[0.001,0.01,1,1,1],'Censoring',cens)
I get the error below:
Error using mlecustom (line 166)
Error evaluating the user-supplied pdf function
'@(t,alpha,beta,b0,b1,b2)exp(b0+b1.*x1+b2.*x2).*(exp((alpha./-beta).*(exp(beta.*t)-1))).^(exp(b0+b1.*x1+b2.*x2)-1).*alpha.*exp(beta.*t).*exp(-(alpha.*(exp(beta.*t)-1))./beta)'.
Error in mle (line 239)
[phat, pci] = mlecustom(data,varargin{:});
Error in mle_MGD_regression (line 22)
[phat,pci] = mle(t,'pdf',custpdf,'cdf',custcdf,'start',[0.001,0.01,1,1,1],'Censoring',cens)
Caused by:
Error using .^
Matrix dimensions must agree.
I can't seem to find the problem with the probability density function?

댓글 수: 4

Ameer Hamza
Ameer Hamza 2020년 3월 29일
Can you share the your data file. It will be easier to track down the error if we have data.
tess hamd
tess hamd 2020년 3월 29일
Yeah sure.
The only difference between this code and previous code which worked is custpdf? When I run
custpdf(t,0.001,0.01,1,1,1)
using your data, t, and your start point, [0.001,0.01,1,1,1], I get all zeros. After a little more digging,
(exp((alpha./-beta).*(exp(beta.*t)-1))).^(exp(b0+b1.*x1+b2.*x2)-1)
returns the zeros, because it is essentially (numbers less than 1).^(insanely huge numbers). Is it possible that there are some parentheses out of place?
tess, the custpdf function returns a vector
custpdf(t,0.001,0.01,1,1,1)
ans =
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
however, it should return a scalar. I think there is some issue in this formula of the cdf function. Can you share the mathematical formula of cdf and pdf.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2020년 3월 29일

댓글:

2020년 3월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by