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: Useful labelling of dummy variables following logit


From   Tim Evans <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: Useful labelling of dummy variables following logit
Date   Fri, 26 Aug 2011 12:47:10 +0100

Nick, Maarten

I'm not sure I could add the title at the moment of creation due to the way I am calling the graphing code, since what I do is use one do file to execute the regression (which I know can change), and then I call another do file from within which essentially codes up all of the variables which will exist in the main dataset and then draw the graph (the format will not change, nor will the variables). Only the regression command changes hence why I have the graphing function in a separate do file. Once this is graphed, I return to my open do file and save the graph with a title I have given it. What I would like to do is add the filename once the graph has been saved. 

:

***BEGIN***
preserve
xi: logit Early1 /*i.INVS2*/ i.eth2 age i.invsurg2 i.region i.dep i.screening2 if dep!=9 & sex==2 & ICD10=="C50" /*
*/			 & !inlist(region, 2, 7, 11) & NEW==2, or

qui do "T:\Requests\Info Requests By Surname\2011\J\Jenkins_8684\Working\labelling"
qui graph export "T:\ Working\Early1_England.png", replace
restore

***EARLY2 Analysis
preserve
xi: logit Early2 /*i.INVS2*/ i.eth2 age i.invsurg2 i.region i.dep if dep!=9 & sex==2 & ICD10=="C50", or

qui do "T:\Requests\Info Requests By Surname\2011\J\Jenkins_8684\Working\labelling"
qui graph export "T:\Working\Early2_UK.png", replace
restore
***END***

This continues for around 12 regressions.

Best wishes

Tim


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: 26 August 2011 12:32
To: [email protected]
Subject: Re: st: Useful labelling of dummy variables following logit

Quite so. The first graph in my example code is just for comparison.

Once you -graph use- a graph you can enter -graph combine- with that
one graph and add a -title()-. This is well documented. Start with
-help graph manipulation-.

Or you can put the -title()- on in the first place.

Nick

On Fri, Aug 26, 2011 at 11:59 AM, Tim Evans <[email protected]> wrote:
> Thanks for the advice again both pretty much seem to do what I want, but I found with Nick's example the first graph wasn't needed so what I ended up with is below - took a bit of fiddling around and I think Maartens version is probably cleaner than mine - one thing I do wonder - I am running different logit models, but essentially graph the same variables (from the same dataset), but I call the graphing code from a different do file to the regressions so that I can keep track of the code easily. Is it possible to write a sequence that will open up all of the graphs once saved, insert the filename as the title and then save and close them again?
>
>
>
>
> :
>
> egen axis= axis(z), label(label2)
> drop if axis ==.
> gsort p estimate min95 max95
> gen order = _n
> labmask order, values(label2)
> count if inlist(flag,0,1)
> local N = r(N)
>
> seperate estimate, by(flag)
>
> twoway bar estimate0 axis, xscale(log) base(1) horizontal barw(0.5) color(gs13) ///
>                xline(1) yla(1/`=_N', noticks valuelabel ang(h)) ||             ///
>                  rcap min95 max95 axis, horizontal               ///
>  ||   bar estimate1 axis, xscale(log) base(1) horizontal barw(0.5) color(red) ///
>                xline(1) yla(1/`=_N', noticks valuelabel ang(h)) ||             ///
>                  rcap min95 max95 axis, horizontal               ///
>                legend(order(3 "Significant" 1 "Not significant")) ytitle("") ///
>  xtitle("odds ratio") ytitle("")
>                **xtitle(`: var label estimate')
> drop  estimate0 estimate1
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Maarten Buis
> Sent: 26 August 2011 09:19
> To: [email protected]
> Subject: Re: st: Useful labelling of dummy variables following logit
>
> On Fri, Aug 26, 2011 at 9:59 AM, Tim Evans <[email protected]> wrote:
>> Having given some more thought to only presenting significant predictors, is it possible to graph all of the predictors, but change the colour of the bars of the significant predictors in order to distinguish them from the others?
>
> In essence that information is already available in your graph: Those
> estimates whose confidence interval includes 1 are not significant.
> However you can also add color, like so:
>
> *-------------------- begin example -------------------
> sysuse nlsw88, clear
>
> replace ttl_exp = ttl_exp / 10 // experience in decades
> replace grade = grade - 12 // center education at meaningful value
> logit union i.race i.south grade ttl_exp, or
>
> foreach v in grade ttl_ex { // continuous variables
>       local l`v' : variable label `v'
>           if `"`l`v''"' == "" { // if no variable label
>                        local l`v' "`v'"
>           }
> }
> foreach v in south race { // factor variables
>        levelsof `v'
>        local `v'levs `r(levels)'
>        foreach l in ``v'levs' {
>                local l`v'_`l' : label (`v') `l'
>                if `"`l`v'_`l''"' == "`l'" { // if no value label
>                        local l`v'_`l' `"`v' == `l'"'
>                }
>        }
> }
>
> parmest, norestore eform
> foreach v in grade ttl_ex {
>   replace parm = "`l`v''" if parm == "`v'"
> }
> foreach v in south race {
>        local i = 1
>        foreach l in ``v'levs' {
>                if `i' == 1 {
>                        drop if parm == "`l'b.`v'" // drop reference
>                }
>                else {
>                        replace parm = "`l`v'_`l''" if parm == "`l'.`v'"
>                }
>                local i = `i' + 1
>        }
> }
> replace parm = "baseline odds" if parm == "_cons"
> egen axis= axis(estimate), label(parm)
>
> twoway bar estimate axis if p < .05 , base(1)        ///
>           horizontal barw(.5) color(red)      ||    ///
>       bar estimate axis if p >= .05, base(1)        ///
>           horizontal barw(.5) color(gs13)           ///
>           xline(1)                                  ///
>                   ylab(1/6, valuelabel ang(h) noticks) ||   ///
>      rcap min95 max95 axis, horizontal              ///
>           legend(order(1 "sign. point estimate"     ///
>                        2 "non sign. point estimate" ///
>                        3 "95% conf. int.") pos(6))  ///
>           xtitle("odds ratio") ytitle("")
> *---------------- 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/

_DISCLAIMER:
This email and any attachments hereto contains proprietary information, some or all of which may be confidential or legally privileged. It is for the exclusive use of the intended recipient(s) only. If an addressing or transmission error has misdirected this e-mail and you are not the intended recipient(s), please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail or any attachments, as this may be unlawful.


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