Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Nested If / then statement in a Bar Graph

From   [email protected]
To   [email protected]
Subject   Re: st: RE: Nested If / then statement in a Bar Graph
Date   Tue, 24 Aug 2004 07:06:00 -0500

----- Original Message -----
From: Clive Nicholas <[email protected]>
Date: Monday, August 23, 2004 10:43 pm
Subject: Re: st: RE: Nested If / then statement in a Bar Graph

> This is pretty neat, Scott, but what if you want to change this to 
> showthe graph as, say, thin(ish) horizontal bars? I changed -bar- 
> to -hbar-
> everywhere in the code, but it threw up error messages, so 
> obviously I was
> doing something wrong! That said, I was able to add extra bars for 
> extravariables without too much difficulty.


Changing -graph bar ... - to -graph hbar...- seems to work for me.  One way to get thinner(ish) bars would be to change to gaps.  Something like

graph hbar (mean) b_* , outergap(100) bargap(250) ///

> That leads to the second question. If you're like me and you're 
> running a
> model with 50 variables, presumably there's no quick-and-dirty 
> workaround.

Sometimes, tables can be nice.  

I suppose, you could pick up the list of variables from -regress- and cycle through them in a more automated manner or pick up the elements you need from e(b) and e(V).

> Third, what if Alex wanted to use beta-weights as opposed to b-scores?
> Unfortunately, -ereturn list- doesn't leave these behind even if 
> you enter
> . reg price disp length, beta
> but, again, maybe there's a workaround here, too. 

Kit Baum's -betacoef- returns the beta coefficients in matrix.   One way would be: 

sysuse auto,clear
qui {
reg price disp length 
matrix A = r(beta)

gen b_disp = A[1,1]
gen b_length = A[1,2]
scalar t_disp = _b[disp] / _se[disp]
scalar t_length = _b[length] / _se[length]

if abs(t_disp) > 1.96 {
	local bar1 "1, bfcolor(red) blcolor(red)"
else {
	local bar1 "1, bfcolor(blue) blcolor(blue)"
if abs(t_length) > 1.96 {
	local bar2 "2, bfcolor(red) blcolor(red)"
else {
	local bar2 "2, bfcolor(blue) blcolor(blue)"
graph hbar (mean) b_* , outergap(100) bargap(250)  ///
    bar(`bar1') bar(`bar2') ytitle("Beta Coefficients") ///
    blabel(bar, position(outside)) 


*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index