Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[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   Thu, 25 Aug 2011 09:08:21 +0100

Hi Maarten,

Thanks for the help again. I've tried your example below, but it fails on the following code:

parmest, norestore eform
Invalid estimates matrix: e(b)
last estimates not found

Any idea what is going on here?

Best wishes


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Maarten Buis
Sent: 24 August 2011 17:43
To: [email protected]
Subject: Re: st: Useful labelling of dummy variables following logit

On Wed, Aug 24, 2011 at 5:41 PM, Tim Evans <[email protected]> wrote:
> Thanks for this, it nearly works for me - I can graph it, but I don't get all of the variable values from the 'axis' column to appear - I only have random ones. Do you know why it does not display all of the variables names (but does display the estimate value)

if you have say 7 estimates than your -ylab()- option should be
-ylab(1/7, valuelabel ang(h) noticks ) to ensure that there is a label
for each estimate. The dropping is not random, Stata tries to find
nice values for labels, so it can easily happen that it only displays
an axis label for every 2nd or 5th parameter. For most graphs makes
perfect sense, just not for ours, so need to explicitly tell Stata to
which values it needs to attach a label.

The added problem here is that Tim is interested in factor variables.
In that case you would not want the variable label but the value
label. I have modified the example further to ensure that happens.

*------------------------ 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(z), label(parm)
twoway bar  estimate axis, base(1) horizontal barw(.5) ///
           xline(1) ylab(1/6, valuelabel ang(h) noticks) ||             ///
      rcap min95 max95 axis, horizontal               ///
           legend(order(1 "point estimate"            ///
                        2 "95% conf. int.") pos(6))   ///
           xtitle("odds ratio") ytitle("")
*--------------------- end example -----------------------------
(For more on examples I sent to the Statalist see: )

Hope this helps,

Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen

*   For searches and help try:

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:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index