Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, 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: Graph Mean SD of continuous variable over categorical variable - but with a twist |

Date |
Tue, 25 Oct 2011 08:58:31 +0100 |

See also SJ-5-4 gr0023 . . . . Stata tip 27: Classifying data points on scatter plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox Q4/05 SJ 5(4):604--606 (no commands) tips for using separate, gray-scale gradation, and text characters as class symbols to classify data points on a scatter plot for technique relevant to the "for each group" part of the question. In a sentence, use -separate- to separate the response into different variables. Nick On Tue, Oct 25, 2011 at 8:35 AM, Maarten Buis <maartenlbuis@gmail.com> wrote: > On Tue, Oct 25, 2011 at 9:02 AM, Lars Folkestad wrote: >> I am trying to depict the differences in mean+-SD of two continuous >> Variables over a categorical variable <snip> >> scatter mean cat || rcap upper lower cat > <snip> >> But this does not give me the option to change the colour of the >> Mean (dot) or the SD (bars) for each group, which visually would >> Be preferable. > > It does give you that possibility, you just need to find the right > options. That command consists of two parts separated by -||-. The > first part graphs mean against the categorical variable and the second > graphs the standard deviation bars against the categorical variable. > To find the options possible after the first command type in Stata > -help twoway scatter- and to find the options possible after the > second command type in Stata -help twoway rcap-. In the example below > I give a silly (and extremely ugly) example of how you can change the > way your graph looks: > > *--------------------- begin example ---------------------- > sysuse auto, clear > egen mean = mean(price) , by(rep78) > egen sd = sd(price), by(rep78) > gen upper = mean + sd > gen lower = mean - sd > > scatter mean rep78 , /// plots the mean against rep78 > msymbol(S) /// change the symbol to a solid square > msize(huge) /// make the marker size huge > color(purple) /// change the color of the symbol to purple > || /// start a new overlay graph > rcap upper lower rep78, /// plots the standard deviation against rep78 > lpattern(longdash) /// make the line dashed > lwidth(thick) /// make the line thick > lcolor(pink) // make the the line pink > *---------------------- end example ----------------------- > (For more on examples I sent to the Statalist see: > http://www.maartenbuis.nl/example_faq ) > * * 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/

**Follow-Ups**:**Re: st: Graph Mean SD of continuous variable over categorical variable - but with a twist***From:*Nick Cox <njcoxstata@gmail.com>

**References**:**st: Graph Mean SD of continuous variable over categorical variable - but with a twist***From:*Lars Folkestad <lfolkestad@health.sdu.dk>

**Re: st: Graph Mean SD of continuous variable over categorical variable - but with a twist***From:*Maarten Buis <maartenlbuis@gmail.com>

- Prev by Date:
**Re: st: Graph Mean SD of continuous variable over categorical variable - but with a twist** - Next by Date:
**st: repeatedly shuffle number sequence** - Previous by thread:
**Re: st: Graph Mean SD of continuous variable over categorical variable - but with a twist** - Next by thread:
**Re: st: Graph Mean SD of continuous variable over categorical variable - but with a twist** - Index(es):