{smcl}
{* 25 Feb 2002}{...}
{hline}
help for {hi:nbfit}
{hline}

{title:Fitting negative binomial distribution by maximum likelihood} 

{p 8 12}{cmd:nbfit} 
{it:varname}
[{cmd:if} {it:exp}] 
[{cmd:in} {it:range}] 
[{it:weight}] 
[, {cmdab:l:og} ]


{title:Description} 

{p}
{cmd:nbfit} fits a negative binomial distribution to a single variable
by the method of maximum likelihood. Frequency weights may
be used to fit variables given in frequency distribution form.

{p} 
The distribution is here parameterised by m (estimated by the mean)
and k:

             Gamma(k + x)               k               x
    pr(x) =  ------------  (k / (k + m))   (m / (k + m))
             Gamma(k) x!

             Gamma(k + x)   k   x
          =  ------------  q   p
             Gamma(k) x!

{p} 
where p = m / (k + m) and q = 1 - p.

{p} 
The estimation is carried out by {cmd:nbreg}. Its {cmd:_b[_cons]} is ln m 
and its {cmd:_b[/lnalpha]} is ln(1 / k).


{title:Option} 

{p 0 4} 
{cmd:log} specifies that the results of {cmd:nbreg} should be displayed.


{title:Example}

{p}Hilborn and Mangel (1997, p.100) give data on incidental capture 
of albatrosses in the New Zealand subantarctic squid trawl fishery, 
1990. (The birds get trapped accidentally in nets or trawl gear or 
cables.) The data are in frequency distribution form: 

{p 4 8}{inp:. input x freq}{p_end}
{p 4}1. 0 807{p_end}
{p 4}2. 1 37{p_end}
{p 4}3. 2 27{p_end}
{p 4}4. 3 8{p_end}
{p 4}5. 4 4{p_end}
{p 4}6. 5 4{p_end}
{p 4}7. 6 1{p_end}
{p 4}8. 7 3{p_end}
{p 4}9. 8 1{p_end}
{p 4}10. 9 0{p_end}
{p 4}11. 10 0{p_end}
{p 4}12. 11 2{p_end}
{p 4}13. 12 1{p_end}
{p 4}14. 13 1{p_end}
{p 4}15. 14 0{p_end}
{p 4}16. 15 0{p_end}
{p 4}17. 16 0{p_end}
{p 4}18. 17 1{p_end}
{p 4}19. end{p_end}

{p 4 8}{inp:. nbfit x [w=freq]} 


{title:Saved values} 

    r(N)      number of values used
    r(mean)   ML estimate of m
    r(k)      ML estimate of k
    r(p)      ML estimate of p
    r(V)      variance-covariance matrix of (m,k,p) (delta method)

{title:References} 

{p}Hilborn, R. and Mangel, M. 1997. 
{it:The ecological detective: confronting models with data.} 
Princeton University Press, Princeton, NJ.

{p}Krebs, C.J. 1999. {it:Ecological methodology.} Benjamin/Cummings, 
Menlo Park, CA.

{p}Rice, J.A. 1995. {it:Mathematical statistics and data analysis.} Duxbury,
Belmont, CA.


{title:Author}

         Nicholas J. Cox, University of Durham, U.K.
         n.j.cox@durham.ac.uk

	 Roberto G. Gutierrez, Stata Corporation
	 rgutierrez@stata.com


{title:Also see}

On-line:  help for {help nbreg} 
 Manual:  {hi:[R] nbreg}

