{smcl}
{* 17nov2003/16may2011}{...}
{hline}
help for {hi:pgamma}
{hline}

{title:Probability plot for data versus fitted gamma distribution}

{p 8 25 2}{cmd:pgamma}{space 1}{it:varname} [{cmd:if} {it:exp}]
[{cmd:in} {it:range}] [{it:weight}] [{cmd:,} {cmdab:alt:ernative} {cmdab:g:rid} 
{cmd:param(}{it:# #}{cmd:)} {cmd:show(}{it:condition}{cmd:)} 
{cmdab:gen:erate(}{it:newvar1 newvar2}{cmd:)} 
{it:graph_options} ]

{p 4 4 2}
where {it:graph_options} are

{p 8 8 2}
{cmd:rlopts(}{it:cline_options}{cmd:)}
{cmd:plot(}{it:plot}{cmd:)}
{cmd:addplot(}{it:addplot}{cmd:)}
{it:scatter_options}
{it:twoway_options}

{p 4 4 2}{cmd:fweight}s and {cmd:aweight}s are allowed; see help {help weights}. 


{title:Description}

{p 4 4 2}
{cmd:pgamma} produces a probability plot for {it:varname} compared with a
two-parameter gamma distribution with 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.  
By default, maximum likelihood estimation is carried out, using 
{help gammafit}, which should be installed separately. 


{title:Remarks} 

{p 4 4 2}In the majority of cases, {cmd:pgamma} will be used to fit an
gamma distribution on the fly and to assess that fit. In some cases, it
may be of interest to compare data with a gamma distribution with 
known or hypothesised parameters, which may be specified using the {cmd:param()}
option. In all cases it is important not only to specify any {cmd:if} or
{cmd:in} restrictions, but also to specify relevant weights, which will (unless
constant) affect the configuration of the plot. 


{title:Options}

{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:grid} is equivalent to {cmd:yla(0(.25)1, grid) xla(0(.25)1, grid)}.

{p 4 8 2}{cmd:param()} may be used to supply parameter values (namely, shape 
and scale parameters) directly for use in estimation of fitted quantiles. 
{it:a} and {it:b} should be provided as separate values in precisely that order.

{p 4 8 2}{cmd:show()} may be used to specify 
that you wish to restrict the graph according to some condition, say 
looking at one tail of the distribution only. Note that {cmd:if} 
and {cmd:in} should not be used for this purpose. 

{p 4 8 2}{cmd:generate()} specifies the names of two new variables, 
the first to hold gamma probabilities and the second to hold 
empirical probabilities. 

{p 4 8 2}{it:graph_options} are
{cmd:rlopts(}{it:cline_options}{cmd:)},
{cmd:plot(}{it:plot}{cmd:)} (Stata 8 only),
{cmd:addplot(}{it:addplot}{cmd:)} (Stata 9 up),
{it:scatter_options}, and
{it:twoway_options}.

{p 4 8 2}
{cmd:rlopts(}{it:cline_options}{cmd:)} affect the rendition of the reference
line; see help {help cline_options}.

{p 4 8 2}
{cmd:plot(}{it:plot}{cmd:)} provides a way to add other plots to the generated
graph; see help {help plot_option} (Stata 8 only).

{p 4 8 2}
{cmd:addplot(}{it:plot}{cmd:)} provides a way to add other plots to the 
generated graph; see help {help addplot_option} (Stata 9 up).

{p 4 8 2}
{it:scatter_options} affect the rendition of the plotted points; see help
{help scatter}.

{p 4 8 2}
{it:twoway_options} are any of the options documented in help
{help twoway_options} excluding {cmd:by()}.  These include options for titling
the graph (see help {help title_options}) and options for saving the graph to
disk (see help {help saving_option}).


{title:Examples}

{p 4 8 2}{cmd:. pgamma spacing}

{p 4 8 2}{cmd:. pgamma spacing, param(20 3)}

{p 4 8 2}{cmd:. pgamma spacing, gen(spacing_gam spacing_emp)} 


{title:Author}

{p 4 4 2}Nicholas J. Cox, Durham University, U.K.{break} 
n.j.cox@durham.ac.uk


{title:References}

{p 4 4 2}
Forbes, C., Evans, M., Hastings, N. and Peacock, B. 2011. 
{it:Statistical distributions.}
New York: 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 gammafit}, {help qgamma} (if installed), {help graph}, {help diagplots}
