# Different results for MaximumLikelihood depending on method?

When I used this command:

EstimatedDistribution[data, BinomialDistribution[n, p],
ParameterEstimator -> {"MaximumLikelihood", Method -> "NMaximize"}]


I get: BinomialDistribution[12, 0.00842065]

with error message:

FindRoot::cvmit: Failed to converge to the requested accuracy or precision within 100 iterations


versus:

EstimatedDistribution[data, BinomialDistribution[n, p],
ParameterEstimator -> {"MaximumLikelihood"}]


I get: BinomialDistribution[4, 0.0252702]

What are actually the differences between the two commands? Which answer should I use?

-
There is no way for us to figure out which result is best without the data. Fortunately, there are algorithms called goodness of fit tests. These tests test how well a given distribution matches some data. This test is a common one: reference.wolfram.com/mathematica/ref/… Run it on the data and the distribution. See which does better. –  Searke Oct 10 '12 at 13:32
The answers you are getting strongly suggest your data consist of counts of rare events. The distribution will be approximately Poisson, which (as the limiting value of Binomial$(n,p)$ for $np$ held constant) is going to be very difficult to differentiate from Binomial distributions with large $n$ (and vanishingly small $p$). The standard errors for $n$ and $p$ ought to tell you that. So the more important issue for you is not which command to use, but whether it's wise to trust the output of any such command here. Perhaps you should be fitting a Poisson distribution from the outset... –  whuber Oct 22 '12 at 15:33

It seems to be matter of which method--FindMaximum vs. NMaximize--is used to maximize the Likelihood function (or more probably the log-likelihood function). Since it is possible to get an analytic form of the likelihood function of the binomial distribution given some data:

SeedRandom[1];
nSamplePoints = 10;
data = RandomVariate[ BinomialDistribution[10, 0.1], nSamplePoints ];

likelihood = Simplify[
Likelihood[BinomialDistribution[n, p], data]
, Assumptions -> {n >= 2}];


Then you can plot this function with ContourPlot (of course n is probably an integer but that's a detail for this purpose):

How to ascertain which combination of n and p gives the maximum likelihood (the mountain top on the contour plot) is a huge topic and there is a whole raft of documentation on function maximization in Mathematica's help. If you have the analytic form, you usually want to use the default method (which then uses the Automatic method of FindMaximum) instead of NMaximize, which doesn't have any knowledge of the gradient of the function to aid it in climbing up the hill but still does the best it can.

In your case, I think that it is even more acute since the likelihood function is so sharp given the very low value for p. (I suspect its overwhelmingly zeros in your data)

-
yes, the proportion of zeros in my data is very high, more than 90%. –  yyasinta Oct 18 '12 at 10:20