Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Graph Mean SD of continuous variable over categorical variable - but with a twist


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: Graph Mean SD of continuous variable over categorical variable - but with a twist
Date   Tue, 25 Oct 2011 09:35:08 +0200

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 )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


http://www.maartenbuis.nl
--------------------------
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index