David Harrison wrote:
> The other option if you want more variables is to produce your own wrapper
> command for both -regress- and -graph bar-, such as:
>
> program define grreg
> version 8
> syntax varlist(min=2 numeric)
> regress `varlist'
> qui {
> tokenize `varlist'
> macro shift
> local vlist `*'
> local blist ""
> local bars ""
> local i 0
> local rel ""
> local tcrit=invttail(e(df_r),.025)
> foreach v of local vlist {
> local i=`i'+1
> tempvar b_`v'
> gen `b_`v'' = _b[`v']
> scalar t_`v' = _b[`v'] / _se[`v']
> local blist "`blist' `b_`v''"
> local rel `"`rel' `i' "`v'""'
> if abs(t_`v') > `tcrit' {
> local bars `"`bars' bar(`i', bcolor(red))"'
> }
> else {
> local bars `"`bars' bar(`i', bcolor(blue))"'
> }
> }
> graph bar (mean) `blist', bargap(30) `bars' ///
> ytitle("Parameter Estimate") blabel(bar, position(outside)) ///
> showyvars yvaroptions(relabel(`rel')) legend(off)
> }
> end
>
> The syntax would then be, e.g., -grreg price disp length- producing both
> the regression and the graph in one go.
>
> Obviously there's lots of scope for more bells & whistles on this like
> -if-, -in- and passing options through to both -regress- and -graph-.
Thanks for this: this is also very good. I wanted to add Scott Merryman's
suggested code from my earlier query:
. betacoef
. matrix A = r(beta)
to this. However, I couldn't work out where this goes so that I could turn
your -grreg- into a graphed regression with the beta weights.
Alternatively, I added -beta- to the fourth line, but this made no
difference to the outcome.
CLIVE NICHOLAS |t: 0(044)191 222 5969
Politics |e: [email protected]
Newcastle University |http://www.ncl.ac.uk/geps
*
* 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/