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

st: Nested If / then statement in a Bar Graph


From   [email protected]
To   [email protected]
Subject   st: Nested If / then statement in a Bar Graph
Date   Mon, 23 Aug 2004 14:08:09 -0400



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/



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