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

From |
Fredrik Wallenberg <fredrik@sims.berkeley.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Simple graph of coefficients and s.e. |

Date |
Fri, 23 Apr 2004 11:20:41 -0700 |

My advisor wanted me to plot the coefficients for some category variables with "whiskers" for the standard errors. The program below does the trick but I'm still left with one issue... I haven't figured out how to get the variable names on the x-axis rather than a number. The names are stored in the e(b) matrix as row names, but I haven't figured out how to get them into a variable.

An example of the output can be found at:

http://sims.berkeley.edu/~fredrik/files/IncReg.jpg

#delimit;

** plot estimation coefficients ** ;

capture program drop graphbeta ;

program define graphbeta ;

version 8.2 ;

args varname ;

quietly { ;

matrix beta = e(b)' ;

matrix var = vecdiag(e(V))' ;

local varnames : rownames(beta) ;

svmat float beta, names(beta) ;

svmat float var, names(betavar) ;

gen lowbound = beta1 - 2*sqrt(betavar1) ;

gen hibound = beta1 + 2*sqrt(betavar1) ;

egen varcount = fill(1 2) ;

};

twoway (rspike lowbound hibound varcount if beta1!=., blwidth(medthick) blpattern(solid) blcolor(maroon)) (scatter beta1 varcount if beta1!=., mcolor(navy)), ytitle(Coefficient +/- 2 s.e.) yline(0) xtitle(`varname' Category Coefficients) legend(off) graphregion(fcolor(white) lcolor(white) lwidth(none)) ;

quietly {;

matrix drop _all ;

drop beta1 - varcount ;

};

end ;

** ;

*

* 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/

- Prev by Date:
**st: RE: 'if' with labels but finds no observations** - Next by Date:
**Re: st: Puzzled by behavior of -recode varlist (.a/.z=.)-** - Previous by thread:
**st: RE: 'if' with labels but finds no observations** - Next by thread:
**st: RE: Simple graph of coefficients and s.e.** - Index(es):

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