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

st: RE: Simple graph of coefficients and s.e.


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Simple graph of coefficients and s.e.
Date   Fri, 23 Apr 2004 19:38:18 +0100

You are possibly missing out on an 
easier solution from Roger Newson's 
-eclplot-. 

Nick 
[email protected] 

Fredrik Wallenberg

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



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