[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Scott Merryman" <smerryman@kc.rr.com> |

To |
<statalist@hsphsun2.harvard.edu> |

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

Date |
Mon, 23 Aug 2004 19:46:08 -0500 |

Alexander, How about something like this: sysuse auto,clear qui { reg price disp length gen b_disp = _b[disp] gen b_length = _b[length] 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 bar (mean) b_* , bargap(30) /// bar(`bar1') bar(`bar2') ytitle("Parameter Estimate") /// blabel(bar, position(outside)) Hope this helps, Scott > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu [mailto:owner- > statalist@hsphsun2.harvard.edu] On Behalf Of > Alexander.D.Rothenberg@frb.gov > Sent: Monday, August 23, 2004 1:08 PM > To: statalist@hsphsun2.harvard.edu > Subject: st: Nested If / then statement in a Bar Graph > > > > > Hello, > > I am making a series of bar graphs in STATA, each of which plots the > magnitudes of certain parameter estimates of different variables in a > regression against each other. I want to somehow indicate on the graph > which variables are significant and which are not, so I was thinking of > changing the color of bars depending on whether or not the parameter > estimate is significantly different from zero. > > In this light, after running my regression, I define: > > generate nafta_b = _b[nafta_der] > scalar nafta_t = _b[nafta_der] / _se[nafta_der] (where nafta_der is one > variable whose parameter estimate I want to plot) > > and I make the following graph: > > graph bar (mean) nafta_b and other similar variables, /// > bargap(30) /// > bar(1, bfcolor(red) blcolor(red) if nafta_t > 1.96) /// > ytitle("Parameter Estimate") > (and other graph options) > > My question is how can I get the bars to change colors, depending on > whether or not the t-statistic is greater than 1.96? The if command > nested > in the bar statement doesn't work, and it won't let me put an if / then > statement outside the statement. Any ideas on what I should do? > > Thank you, in advance, for your assistance with this. > * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: RE: Nested If / then statement in a Bar Graph***From:*"Clive Nicholas" <Clive.Nicholas@newcastle.ac.uk>

**References**:**st: Nested If / then statement in a Bar Graph***From:*Alexander.D.Rothenberg@frb.gov

- Prev by Date:
**RE:st: Part II: An error in the xtabond-description** - Next by Date:
**Re: st: RE: Nested If / then statement in a Bar Graph** - Previous by thread:
**st: Nested If / then statement in a Bar Graph** - Next by thread:
**Re: st: RE: Nested If / then statement in a Bar Graph** - Index(es):

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