Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: qplot , over() |

Date |
Sat, 24 Mar 2012 08:16:42 +0000 |

I think you meant bysort foreign (mpg) : Either way, the -egen- route is convenient because it does the right thing with missing values. More importantly, I agree with the broad point. We are often flipping between two opposite truths: 1. A dedicated program does almost all the work for you, including dealing with awkward details. 2. If you break down the problem into soluble sub-problems, you can work out the problem yourself with a few lines of code. Nick On Fri, Mar 23, 2012 at 10:17 PM, Keith Dear <keithdear4@gmail.com> wrote: > Thanks Nick, the new version does what I wanted. > > In passing -- while I agree it's not hard to DIY this, in fact this is > a nice example of why it's better to use a provided (authorised) > program when possible. Instead of your careful code, I would have > written: > . bys mpg (foreign): gen pp=(_n-0.5)/_N > It took me some thought to see why you didn't do it that way (they > give exactly the same result for the auto data). > Keith > > > On 23 March 2012 23:53, Nick Cox <njcoxstata@gmail.com> wrote: >> By the way, a do-it-yourself approach is easier than might be thought >> >> sysuse auto, clear >> egen rank = rank(mpg), unique by(foreign) >> egen n = count(mpg), by(foreign) >> gen pp = (rank - 0.5 ) / n >> separate mpg, by(foreign) veryshortlabel >> scatter mpg? pp >> >> SJ-7-2 gr0027 . . Stata tip 47: Quantile-quantile plots without programming >> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox >> Q2/07 SJ 7(2):275--279 (no commands) >> tip on producing various quantile-quantile (Q-Q) plots >> >> Note that this recipe is strong enough to cope with ties and missing >> values and flexible in that you can insert your own definition of >> plotting positions (-pp- above) if you don't like (i - 0.5) / n for >> some reason. >> >> Nick >> >> On Fri, Mar 23, 2012 at 12:36 PM, Nick Cox <njcoxstata@gmail.com> wrote: >>> In revising -qplot- for SJ 10-4 I inadvertently introduced a bug in >>> implementation of the -over()- option. I thought no one had noticed >>> but me, but Keith has been bitten by it. >>> >>> The bug has already been fixed in a update due shortly in SJ 12-1. I >>> will send Keith a copy of the revised files. >>> >>> Nick >>> >>> On Fri, Mar 23, 2012 at 12:22 PM, Keith Dear <keithdear4@gmail.com> wrote: >>> >>>> How can I get several quantile plots in one diagram? >>>> (There have been past threads on this, but I found no mention of what >>>> I am getting.) >>>> >>>> sysuse auto >>>> replace mpg=mpg/2 if foreign // for greater separation >>>> qplot mpg, by(foreign) // two distinct curves, which I would like >>>> to plot together >>>> qplot mpg, over(foreign) // points on a single curve, not what I expected >>>> >>>> Am I misunderstanding the help file? It seems to imply that by() and >>>> over() give the same set of curves, which is what I want but isn't >>>> what happens: >>>> >>>> ---- help qplot >>>> by(varname[, suboptions]) specifies that calculations be carried out >>>> separately for each distinct value of a >>>> specified single variable. Results will be shown separately in >>>> distinct panels. See [G] by_option. >>>> over(varname) specifies that calculations be carried out separately >>>> for each distinct value of a specified >>>> single variable. Curves will be shown together within the >>>> same panel. over() is only allowed with a single >>>> varname. >>>> ---- >>>> >>>> -qplot- is by NJC out of -net install gr42_5.pkg- >> * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: qplot , over()***From:*Keith Dear <keithdear4@gmail.com>

**Re: st: qplot , over()***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: qplot , over()***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: qplot , over()***From:*Keith Dear <keithdear4@gmail.com>

- Prev by Date:
**Re: st: Use varlabel in expressions** - Next by Date:
**Re: st: Use varlabel in expressions** - Previous by thread:
**Re: st: qplot , over()** - Next by thread:
**st: Calling -ml- program with more than one equation!** - Index(es):