{smcl} {* 17nov2003/16may2011}{...} {hline} help for {hi:gammafit} {hline} {title:Fitting a two-parameter gamma distribution by maximum likelihood} {p 8 17 2}{cmd:gammafit} {it:varname} [{it:weight}] [{cmd:if} {it:exp}] [{cmd:in} {it:range}] [{cmd:,} {cmdab:alpha:var(}{it:varlist1}{cmd:)} {cmdab:beta:var(}{it:varlist2}{cmd:)} {cmdab:alt:ernative} {cmdab:r:obust} {cmdab:cl:uster(}{it:clustervar}{cmd:)} {cmdab:l:evel(}{it:#}{cmd:)} {it:maximize_options} ] {p 4 4 2}{cmd:by} {it:...} {cmd::} may be used with {cmd:gammafit}; see help {help by}. {p 4 4 2}{cmd:fweight}s and {cmd:aweight}s are allowed; see help {help weights}. {title:Description} {p 4 4 2} {cmd:gammafit} fits by maximum likelihood a two-parameter gamma distribution to a distribution of a variable {it:varname}. The distribution has probability density function for variable {it:x} >= 0, shape parameter {it:a} > 0 and scale parameter {it:b} > 0 of [1 / ({it:b}^{it:a} gamma({it:a}))] {it:x}^({it:a} - 1) exp(-{it:x} / {it:b}). See also the {cmd:alternative} option. {title:Options} {p 4 8 2}{cmd:alphavar(}{it:varlist1}{cmd:)} and {cmd:betavar(}{it:varlist2}{cmd:)} allow the user to specify each parameter as a function of the covariates specified in the respective variable list. A constant term is always included in each equation. {p 4 8 2}{cmd:alternative} specifies use of an alternative parameterisation [({it:b}^{it:a} / gamma({it:a}))] {it:x}^({it:a} - 1) exp(-{it:bx}). {p 4 8 2}{cmd:robust} specifies that the Huber/White/sandwich estimator of variance is to be used in place of the traditional calculation; see {hi:[U] 23.14 Obtaining robust variance estimates}. {cmd:robust} combined with {cmd:cluster()} allows observations which are not independent within cluster (although they must be independent between clusters). {p 4 8 2}{cmd:cluster(}{it:clustervar}{cmd:)} specifies that the observations are independent across groups (clusters) but not necessarily within groups. {it:clustervar} specifies to which group each observation belongs; e.g., {cmd:cluster(personid)} in data with repeated observations on individuals. See {hi:[U] 23.14 Obtaining robust variance estimates}. Specifying {cmd:cluster()} implies {cmd:robust}. {p 4 8 2}{cmd:level(}{it:#}{cmd:)} specifies the confidence level, in percent, for the confidence intervals of the coefficients; see help {help level}. {p 4 8 2}{cmd:nolog} suppresses the iteration log. {p 4 8 2}{it:maximize_options} control the maximization process; see help {help maximize}. If you are seeing many "(not concave)" messages in the log, using the {cmd:difficult} option may help convergence. {title:Saved results} {p 4 4 2}In addition to the usual results saved after {cmd:ml}, {cmd:gammafit} also saves the following, if no covariates have been specified: {p 4 4 2}{cmd:e(alpha)} and {cmd:e(beta)} are the estimated gamma parameters. {p 4 4 2}The following results are saved regardless of whether covariates have been specified: {p 4 4 2}{cmd:e(b_alpha)} and {cmd:e(b_beta)} are row vectors containing the parameter estimates from each equation. {p 4 4 2}{cmd:e(length_b_alpha)} and {cmd:e(length_b_beta)} contain the lengths of these vectors. If no covariates are specified in an equation, the corresponding vector has length equal to 1 (the constant term); otherwise, the length is one plus the number of covariates. {title:Examples} {p 4 8 2}{cmd:. gammafit mpg} {title:Authors} {p 4 4 2}Nicholas J. Cox, Durham University{break}n.j.cox@durham.ac.uk {p 4 4 2}Stephen P. Jenkins, London School of Economics{break}s.jenkins@lse.ac.uk {title:References} {p 4 4 2} Forbes, C., Evans, M., Hastings, N. and Peacock, B. 2011. {it:Statistical distributions.} Hoboken, NJ: John Wiley. {p 4 4 2} Johnson, N.L., Kotz, S. and Balakrishnan, N. 1994. {it:Continuous univariate distributions: Volume 1.} New York: John Wiley. {p 4 4 2} Kleiber, C. and Kotz, S. 2003. {it:Statistical size distributions in economics and actuarial sciences.} Hoboken, NJ: John Wiley. {title:Also see} {p 4 13 2} Online: help for {help pgamma} (if installed), {help qgamma} (if installed)