# 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?

-

– 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

## 1 Answer

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
lang-mma
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 6, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.8757997751235962, "perplexity_flag": "middle"}