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: Thread-Index: Ac049lzDw8LzBnUBQd+6mSCfgPrdJg==


From   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: Thread-Index: Ac049lzDw8LzBnUBQd+6mSCfgPrdJg==
Date   Thu, 24 May 2012 10:33:10 -0400

Amal Khanolkar <[email protected]>:
Type
 help weight
to read about weights; if you don't have a pweight finalwgt, then you
should not be typing [pw=finalwgt].
Read
 help local
to learn about the use of locals and
 help extended_fcn
to see what `:lab race 1' evaluates to
(see "label" under "Macro extended functions for extracting data attributes").

You have fractured my example code; if you want to write out the
titles, type e.g.

vioplot bw if motherland3==1, ti(Sweden) name(e1)

and note that graph combine works on graph names, not your titles:

gr combine e1 e2 e3, nocop ycommon row(1) name(vio)

Try instead:

clear all
webuse nhanes2
ren bmi bw
ren agegrp motherland3
* above sets up fake data
ren motherland3 m
forv i=1/6 {
loc l "col(green*`=1+(`i'-3)/3')"
loc d den(`l') bar(`l') line(`l') med(`l')
vioplot bw if m==`i', ti(`:lab (m) `i'') `d' name(e`i')
}
gr combine e1 e2 e3 e4 e5 e6, nocop ycommon row(1)

On Thu, May 24, 2012 at 10:07 AM, Amal Khanolkar <[email protected]> wrote:
> Dear Austin,
>
> Based on the code you suggested, I have the following:
>
> loc c vioplot bw [pw=finalwgt]
> `c' if motherland3==1, ti(`:lab Sweden') den(col(blue)) name(e1)
> `c' if motherland3==2, ti(`:lab NA') den(col(green)) name(e2) ysc(off)
> `c' if motherland3==3, ti(`:lab Iran') den(col(edkblue)) name(e3) ysc(off)
> gr combine Sweden NA Iran, nocop ycommon row(1) name(vio)
> byhist bw, by(motherland3) frac tw(leg(col(1)))
>
>
> - where bw is the continous outcome whose distributions I would like to produce by the categorical variable motherland3 which has 10 categories.
>
> - I've just wirtten the lines for the first 3 categories of the motherland3 variable above.
>
> -However I keep getting a error message that the line 'c' if motherland3==1....' is invalid syntax. Could you please tell me what I'm doing wrong and what exactly the 'c' signifies?
>
> I also want to know what the (pw=finalwgt) does.
>
> Thanks a lot!
>
> Regards,
>
> /Amal.
>
> Amal Khanolkar, PhD candidate,
> Centre for Health Equity Studies (CHESS),
> Karolinska Institutet,
> 106 91 Stockholm.
>
> Ph# +46(0)8 162584/+46(0)73 0899409
> www.chess.su.se
> ________________________________________
> From: [email protected] [[email protected]] on behalf of Austin Nichols [[email protected]]
> Sent: 23 May 2012 20:25
> To: [email protected]
> Subject: Re: st: Thread-Index: Ac049lzDw8LzBnUBQd+6mSCfgPrdJg==
>
> Amal Khanolkar <[email protected]>:
> Try also :
>
> ssc inst vioplot, replace
> ssc inst byhist, replace
> clear all
> webuse nhanes2
> la var race "Race"
> loc c vioplot bpsystol [pw=finalwgt]
> `c' if race==1, ti(`:lab race 1') den(col(blue)) name(r1)
> `c' if race==2, ti(`:lab race 2') den(col(green)) name(r2) ysc(off)
> `c' if race==3, ti(`:lab race 3') den(col(edkblue)) name(r3) ysc(off)
> gr combine r1 r2 r3, nocop ycommon row(1) name(vio)
> byhist bpsystol, by(race) frac tw(leg(col(1)))
>
>
> On Wed, May 23, 2012 at 11:44 AM, Nick Cox <[email protected]> wrote:
>> "plot distributions" is a bit open-ended, but
>>
>> -twoway kdensity-
>>
>> -dotplot-
>>
>> -distplot- (SJ)
>>
>> -qplot- (SJ)
>>
>> -stripplot- (SSC)
>>
>> give you some ways of approaching this. FWIW, different colours are
>> not needed (or even possible) with -dotplot-.
>>
>> On Wed, May 23, 2012 at 4:11 PM, Amal Khanolkar <[email protected]> wrote:
>>
>>> I would like to know how I can plot several distributions of a continuous variable, say birth weight in different colours  by ethnic groups in the graph?

*
*   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