Bookmark and Share

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]

Re: st: Question on graph twoway and graph combine


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Question on graph twoway and graph combine
Date   Wed, 7 Dec 2011 10:06:45 +0000

OK; I see -- in broad terms -- what you are doing. I guess it would
take a fair amount of re-writing your code to get to the point where
-by()- would seem easy, so what you are doing seems practical. Thanks
for the explanation.

Nick

On Wed, Dec 7, 2011 at 9:39 AM, Alberto R Osella
<arosella@irccsdebellis.it> wrote:
> Dear Nick,
> I'm using -seqlogit-. Here a portion of code:
> xi: seqlogit steato_grade i.StatCiv Etarecl glicemia i.scalacat GOT GPT ///
>         if Sesso == 0, or                 ///
>         tree(0:1 2 3 , 1:2 3 , 2 : 3)     ///
>         ofinterest(BMI) over(Etarecl)          ///
>         levels(0=0, 1=1.5, 2=4, 3=5.1)
>
> preserve
>
> keep if e(sample)
>
> replace StatCiv=2
>
> sum BMI, meanonly
> replace BMI = r(mean)
> replace _BMI_X_Etarecl = BMI*Etarecl
> bys Etarecl : keep if _n == 1
>
>
>
> predict wM* , trweight
> _estimates hold model1
>
> mkspline  edad 8= Etarecl if Sesso==0
> regress wM1 edad1-edad8
> predict SwM1
> regress wM2 edad1-edad8
> predict SwM2
> regress wM3 edad1-edad8
> predict SwM3
> drop edad1-edad8
>
> _estimates unhold model1
>
> forvalues i = 1/3 {
>    gen contr`i' = SwM`i'*([#`i']_b[BMI]+ [#`i']_b[ _BMI_X_Etarecl]*Etarecl)
> }
>
> gen contr0 = 0
> replace contr2 = contr1 + contr2
> replace contr3 = contr2 + contr3
>
> twoway rarea contr0 contr1 Etarecl  || ///
>       rarea contr1 contr2 Etarecl  || ///
>       rarea contr2 contr3 Etarecl,  ///
>       xlab(2(2)8)                ///
>       legend(order( 1 "Light or more vs. no" ///
>                     2 "Moderate or more vs. light or less" ///
>                     3 "Severe vs Moderate or less" ) pos(6))
> graph save uomini, replace
>
>
> I've said "I can't use". It may be: " I don't know how to use the by()
> option".
> Best
>
>
> Alberto R. Osella, MD, PhD
> Laboratorio di Epidemiologia e Biostatistica
> IRCCS Saverio de Bellis
> Via Turi, 27
> 70013 Castellana Grotte (BA)
> Italia
> Tel:    +39 0804994655
> Fax:    +39 0804994650
> e-mail: arosella@irccsdebellis.it
>
>
> Il 07/12/2011 10:16, Nick Cox ha scritto:
>>
>> That's good advice, but I don't understand why -by()- couldn't be used
>> in the first place. What does any estimation process have to do with
>> graphing?
>>
>> Nick
>>
>> On Wed, Dec 7, 2011 at 9:09 AM, Phil Clayton
>> <philclayton@internode.on.net>  wrote:
>>
>>> You could try -findit grc1leg-
>>>
>>> On 07/12/2011, at 8:09 PM, Alberto R Osella wrote:
>>>
>>>> I'm using Stata 12.0 on W7. I've drawn two graphs (one for each sex) by
>>>> using -graph twoway- and then I've combined them by using -graph combine-.
>>>> I've drawn graphics separately because I can't using the by() option as a
>>>> result of the estimation process. The resulting combine graph has two
>>>> legends (the same) and I want a graph with only one legend.
>>

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index