help for qgamma 

Quantile-quantile plot for data versus fitted gamma distribution

qgamma varname [if exp] [in range] [weight] [, alternative grid param(# #) show(condition) generate(newvar) graph_options ]

where graph_options are

rlopts(cline_options) plot(plot) addplot(plot) scatter_options twoway_options

fweights and aweights are allowed; see help weights.


qgamma plots the quantiles of varname against the quantiles of a two-parameter gamma distribution with probability density function for variable x >= 0, shape parameter a > 0 and scale parameter b > 0 of [1 / (b^a gamma(a))] x^(a - 1) exp(-x / b). See also the alternative option. By default, maximum likelihood estimation is carried out, using gammafit, which should be installed separately.


In the majority of cases, qgamma 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 param() option. In all cases it is important not only to specify any if or in restrictions, but also to specify relevant weights, which will (unless constant) affect the configuration of the plot.


alternative specifies use of an alternative parameterisation [(b^a / gamma(a))] x^(a - 1) exp(-bx).

grid adds grid lines at the .05, .10, .25, .50, .75, .90, and .95 quantiles.

param() may be used to supply parameter values (namely, shape and scale parameters) directly for use in estimation of fitted quantiles. a and b should be provided as separate values in precisely that order.

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 if and in should not be used for this purpose.

generate() specifies the name of a new variable to hold values of fitted gamma quantiles.

graph_options are rlopts(cline_options), plot(plot) (Stata 8 only), addplot(plot) (Stata 9 up), scatter_options , and twoway_options.

rlopts(cline_options) affect the rendition of the reference line; see help cline_options.

plot(plot) provides a way to add other plots to the generated graph; see help plot_option (Stata 8 only).

addplot(plot) provides a way to add other plots to the generated graph; see help addplot_option (Stata 9 up).

scatter_options affect the rendition of the plotted points; see help scatter.

twoway_options are any of the options documented in help twoway_options excluding by(). These include options for titling the graph (see help title_options) and options for saving the graph to disk (see help saving_option).


. qgamma spacing

. qgamma spacing, param(20 3)

. qgamma spacing, gen(spacing_g)


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


Forbes, C., Evans, M., Hastings, N. and Peacock, B. 2011. Statistical distributions. New York: John Wiley.

Johnson, N.L., Kotz, S. and Balakrishnan, N. 1994. Continuous univariate distributions: Volume 1. New York: John Wiley.

Kleiber, C. and Kotz, S. 2003. Statistical size distributions in economics and actuarial sciences. Hoboken, NJ: John Wiley.

Also see