Matrix dimensions must agree
Show older comments
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 Comments
Ameer Hamza
on 29 Mar 2020
Can you share the your data file. It will be easier to track down the error if we have data.
tess hamd
on 29 Mar 2020
Tommy
on 30 Mar 2020
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?
Ameer Hamza
on 30 Mar 2020
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.
Answers (0)
Categories
Find more on Binomial Distribution in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!