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 11:59:25 +0100

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 )

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/

_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