Thanks to Kit Baum for his ever efficient support, qqplotg is now available from SSC. Stata 8.2 is needed.
This is a variant on official command qqplot and thus needs some small explanations.
I seem to have been writing small or even large variants on qqplot since at least 1998. Some of those variants may have been posted on the old Statalist, but if so they are now hard to find and retrieve.
For the record:
qqplot2 on SSC is a 1998 beast from me for Stata 5 and is not of current interest, unless it is called in a do-file or command you use, which is unlikely but not impossible, so we will leave it in peace on SSC.
qqplot3 is a variant on SSC by Ariel Linden with leading point support for weights, which is fine.
This one isn't called qqplot4 because it doesn't in any sense supersede qqplot3, but it does incorporate the ideas of supporting comparison of groups and of being able to generate new variables. So "g" seems to fit generalized, group, and generate, which is good enough for me.
Recently I mentioned the idea of plotting difference versus mean, for quantiles, https://www.statalist.org/forums/for...v-smirnov-test,
and indeed that thread reminded me of my earlier work. So I blew the dust off an unpublished 2011 program, which lay behind my support for Ariel, and added a help file.
Here are some example applications.
QQ1 is a basic plot comparing domestic and foreign cars. The reference line is of equality and we don't see a parallel pattern, which is what is behind (notably) a t test which focuses on the difference between means.

Naturally, domestic and foreign cars aren't paired, but what you see are corresponding quantiles calculated by interpolation within the larger set. Think of the trickery as a simple extension of plotting minimum vs minimum, maximum vs maximum, median vs median, and so forth.
QQ2 uses the flip option to swap the categories. So, you don't need to recode a group variable if the comparison strikes you as the wrong way round.

QQ3 plots differences versus means for paired quantiles. The combination of shift and tilt is even clearer.

So, we should be willing to look at the data on transformed scale -- which doesn't mean (ultimately) transforming the variable. It could mean using (e.g.) generalized linear models with a suitable link function.
Reciprocals are a natural candidate on dimensional grounds. QQ4 shows the result. Logarithms may appeal otherwise and are strongly competitive QQ5 shows that result.
(Otherwise put:as the range of the outcome here is only about 3-fold, that's not enough for reciprocal and logarithm to behave very differently.)


This is a variant on official command qqplot and thus needs some small explanations.
I seem to have been writing small or even large variants on qqplot since at least 1998. Some of those variants may have been posted on the old Statalist, but if so they are now hard to find and retrieve.
For the record:
qqplot2 on SSC is a 1998 beast from me for Stata 5 and is not of current interest, unless it is called in a do-file or command you use, which is unlikely but not impossible, so we will leave it in peace on SSC.
qqplot3 is a variant on SSC by Ariel Linden with leading point support for weights, which is fine.
This one isn't called qqplot4 because it doesn't in any sense supersede qqplot3, but it does incorporate the ideas of supporting comparison of groups and of being able to generate new variables. So "g" seems to fit generalized, group, and generate, which is good enough for me.
Recently I mentioned the idea of plotting difference versus mean, for quantiles, https://www.statalist.org/forums/for...v-smirnov-test,
and indeed that thread reminded me of my earlier work. So I blew the dust off an unpublished 2011 program, which lay behind my support for Ariel, and added a help file.
Here are some example applications.
Code:
sysuse auto, clear qqplotg mpg, group(foreign) title(miles per gallon) name(QQ1, replace) qqplotg mpg, group(foreign) flip title(miles per gallon) name(QQ2,replace) qqplotg mpg, group(foreign) flip diffvsmean title(miles per gallon) name(QQ3, replace) gen recmpg = 100/mpg qqplotg recmpg, group(foreign) diffvsmean title(gallons per 100 miles) name(QQ4, replace) gen lnmpg = ln(mpg) qqplotg recmpg, group(foreign) diffvsmean title(ln miles per gallon) name(QQ5, replace)
Naturally, domestic and foreign cars aren't paired, but what you see are corresponding quantiles calculated by interpolation within the larger set. Think of the trickery as a simple extension of plotting minimum vs minimum, maximum vs maximum, median vs median, and so forth.
QQ2 uses the flip option to swap the categories. So, you don't need to recode a group variable if the comparison strikes you as the wrong way round.
QQ3 plots differences versus means for paired quantiles. The combination of shift and tilt is even clearer.
So, we should be willing to look at the data on transformed scale -- which doesn't mean (ultimately) transforming the variable. It could mean using (e.g.) generalized linear models with a suitable link function.
Reciprocals are a natural candidate on dimensional grounds. QQ4 shows the result. Logarithms may appeal otherwise and are strongly competitive QQ5 shows that result.
(Otherwise put:as the range of the outcome here is only about 3-fold, that's not enough for reciprocal and logarithm to behave very differently.)
Comment