Good questions.
Question 1.
-stripplot- does not support two or more -over()- options.
But I owe to Hermione Granger a trick that makes that less of a
limitation than it should be. (Economists and econometricians are
reminded that referring to this as the Granger trick may well be
misunderstood.)
Use an -over()- and -by()- in this way:
stripplot mpg, over(foreign) by(rep78, col(1) compact note("")) ///
subtitle(, pos(9) placement(e) nobexpand bcolor(none) ring(1)) ///
box(bfcolor(ltblue)) scheme(s1color) ytitle(Repair record and car type)
Note that the -subtitle()- option is not a suboption of -by()-.
Hermione would want me to emphasise that you have to get this just
right.
Question 2.
-stripplot- does not support weights. That is tacit in the help and
explicit in the code.
As author, I have never wanted them to date. However, there is a clear
possibility that if you want -box- or -bar- information you would want
that to be based on appropriate weights. The best you can do at present
is either or both of
* Cloning -stripplot- and adding them yourself to the code.
* Calculating the required information upstream of -stripplot- and using
its -addplot()- option to show that, in the spirit of previous examples
in this thread.
Nick
[email protected]
Aca N.T.
Some other questions came up in mind:
1. How to create such graph by another subgroup? This would look like
producing a conventional boxplot using -gr hbox var1, over(var2)
over(var3)-
2. Is it possible to take weight into account when using stripplot?
On Mon, Oct 13, 2008 at 4:01 PM, Nick Cox <[email protected]> wrote:
> The second example, like the first, requires that -mean- exists as a
> variable first,
> e.g. from
>
> egen mean = mean(mpg), by(foreign)
>
> Thanks to Martin for the correction.
>
> Aca N.T.
>
> Thanks Nick, it works well. I didnt get any error message as Martin
> did..
>
> On Mon, Oct 13, 2008 at 5:12 AM, Martin Weiss <[email protected]>
> wrote:
>
>> Is "mean" defined somewhere in this code? I get "r(111)" "variable
> mean not
>> found"...
>
> "Nick Cox" <[email protected]>
>
>>> Example of orthodox box plot follows. N.B. that this requires prior
>>> installation of -egenmore- from SSC.
>>>
>>> sysuse auto, clear
>>>
>>> egen adju = adju(mpg), by(foreign)
>>>
>>> egen adjl = adjl(mpg), by(foreign)
>>>
>>> egen loq = pctile(mpg), by(foreign) p(25)
>>>
>>> egen upq = pctile(mpg), by(foreign) p(75)
>>>
>>> stripplot mpg, ///
>>> over(foreign) ms(none) box(bfcolor(ltblue)) yla(, noticks)
pstyle(p1)
>>> ///
>>> addplot(rcap adjl adjl foreign, horizontal pstyle(p1) ///
>>> || rcap adju adju foreign, horizontal pstyle(p1) ///
>>> || rspike upq adju foreign, horizontal pstyle(p1) ///
>>> || rspike loq adjl foreign, horizontal pstyle(p1) ///
>>> || scatter foreign mpg if !inrange(mpg, adjl, adju), mcolor(navy)
>>> ///
>>> || scatter foreign mean, ms(D) mcolor(navy) msize(*2))
>
> Nick Cox
>
>>> One way to do this through marker symbols, as requested, is through
>>> -stripplot- from SSC.
>>>
>>> sysuse auto, clear
>>>
>>> egen mean = mean(mpg), by(foreign)
>>>
>>> stripplot mpg, over(foreign) box stack centre height(0.2) ms(sh)
>>> addplot(scatter foreign mean, ms(Dh) msize(*3))
>>>
>>> With more work, you can come arbitrarily close to more conventional
>>> forms of the box plot.
>
> Martin Weiss
>
>>> Admittedly, my earlier solution did not give you the dot you were
>>> looking
>>> for, but a reference line. If you have Stata 10, fire up the graph
>>> editor
>>> afterwards, use the -add marker- tool and place the marker onto the
>>> reference line. Then highlight the reference line and kill it...
>>> If -gr box- were part of the -twoway- family of graphs, one could
>>> imagine
>>> overlaying it with a -scatteri- to get the mean onto the graph more
>>> reliably
>>> than this...
>>>
>>>> **********
>>>> sysuse auto, clear
>>>> su price, mean
>>>> graph box price, box(1, fcolor(none)) yline(`r(mean)')
>>>> **********
>
> Aca N.T.
>
>>>>> Does anyone know how to put mean (preferably marked as dot) within
>>>
>>> the
>>>>>
>>>>> box using -gr box-?
*
* 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/