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
Maarten Buis <[email protected]>
To
[email protected]
Subject
Re: st: Useful labelling of dummy variables following logit
Date
Fri, 26 Aug 2011 10:19:27 +0200
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/