Custom distribution in Distribution Fitting Tool

2 views (last 30 days)
Dear all,
I am trying to fit an inverse Gamma distribution to a random sample.Initially, I coded the inverse Gamma distribution and then import it to the dfittool. The problem is that when I attempt to fit the distribution and obtain the mle parameters it is not listed there. There are only a few other distributions in the drop down list that you are allowed to fit to. Does this indicate an error or that the inverse gamma is not a good fit?
I also get an error when importing the distribution:
??? Java exception occurred: java.lang.NullPointerException at com.mathworks.toolbox.stats.DistributionFitting.addFitType(DistributionFitting.java:296)
Error in ==> dfsetdistributions at 20 dft.addFitType('addparamfit',a.name, a.code, a.pnames, a.pdescription, ... Error in ==> dfcustomdist at 99 dfsetdistributions(dft,dists);
??? Error while evaluating uimenu Callback
I am confused and anyone's help will be appreciated.
BEst Regards,
Konstantinos

Accepted Answer

Tom Lane
Tom Lane on 13 Sep 2011
Konstantinos, this does not indicate a bad fit, as no preliminary fit is attempted. Distributions could be ruled out if they are inconsistent with the data in some way. These include discrete distributions for non-integer data, and positive distributions for data containing negative values.
The error message is going to be hard to figure out remotely. If you feel like sending the file you imported to tlane at mathworks dot com, I'll take a look.

More Answers (2)

Konstantinos
Konstantinos on 14 Sep 2011
Hi and thanks for your reply. I have managed to solve this problem, however I am not running into mle problems. For example, having generated a random sample and then attempting to fit the inverse gamma on it I get this warning message:
Warning: Maximum likelihood estimation did not converge. Iteration limit exceeded.
As I found out one may use the following command:
options = statset('MaxIter',300, 'MaxFunEvals',600);
in order to change the max number of iterations, however this did not resolve the problem in my case. Is there any advice on this?
Thanks a lot once more.
Konstantinos

Tom Lane
Tom Lane on 15 Sep 2011
Konstantinos, I am not sure but here are some things to check. First, you create an options structure and supply it to mle like this:
load carsmall
opt = statset('mlecustom')
opt.MaxIter = 3;
mle(Weight,'dist','tlocationscale','opt',opt)
When I do this I hit the iteration limit. Then if I try
opt.MaxIter = 333;
mle(Weight,'dist','tlocationscale','opt',opt)
this time I don't hit the iteration limit but I hit the function evaluation limit instead. I can increase that as well:
opt.MaxFunEvals = 1000;
mle(Weight,'dist','tlocationscale','opt',opt)
This lets the estimation proceed to convergence.

Community Treasure Hunt

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

Start Hunting!