cquantile -- generate corresponding quantiles
cquantile varname1 varname2 [if] [in] , generate(newvar1 newvar2)
cquantile varname [if] [in] , by(groupvar) generate(newvar1 newvar2)
cquantile generates corresponding quantiles, namely, those quantiles that would be shown on a quantile-quantile plot, as in qqplot. Given either two numeric variables, or one numeric variable and one grouping variable defining two groups, two new variables are generated containing the quantiles. One of those new variables contains values identical to those in one of the existing variables or groups, and the other contains corresponding quantiles. The two new variables are aligned lowest to lowest, ..., highest to highest. There is thus some redundancy introduced, but having both variables handy is intended to be a convenience, especially for further graphics. For example, quantile-quantile plots are often inspected for additive or multiplicative structure. A direct way to check for either would be to plot difference of quantiles versus their mean or ratio of quantiles versus their geometric mean.
generate() specifies two new variable names to hold the quantiles.
by() specifies a group variable to specify precisely two groups of varname, after any if or in restrictions have been noted. by() may be only be specified with a single variable name.
. cquantile length width, gen(Qlength Qwidth) . gen diff = Qlength - Qwidth . gen mean = (Qlength + Qwidth) / 2 . scatter diff mean, yti(length - width) xti((length + width)/2)
. cquantile mpg, by(foreign) generate(mpg0 mpg1) . qqplot mpg?
Nicholas J. Cox, Durham University email@example.com
Manual: [R] diagnostic plots
Online: qqplot, separate, fixsort (if installed), pairplot (if installed)