Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Re: Plotting regression coefficients


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Re: Plotting regression coefficients
Date   Wed, 2 Jun 2010 12:55:02 +0100

In passing I record distaste at this primitive practice, more suited to
restaurant or hotel guides than to statistical reports. For more
exegesis of my prejudice, see 

http://www.stata.com/statalist/archive/2007-03/msg00646.html

Now to the question. I can think of three routes: 

1. Use the -plot()- or -addplot()- option of -eclplot- and add a string
variable via marker labels. The canonical call is -addplot(scatter y x,
ms(none) mla(whatyouwant) mlabpos(0))-. 

2. Use -text()- options to add text in particular places. 

3. Use the Graph Editor. 

Nick 
[email protected] 

Miranda Kim

I wonder is there a way of plotting stars that represent the
significance of the respective p-value above each regression coefficient
(95%CI), in the eclplot generated by Martin's code below?
Many thanks,
Miranda
*************
clear*
set obs 10000
//get Roger`s -parmest- 
capt which parmest
if _rc ssc inst parmest
gen personid=_n 
gen bmi0 = rnormal()
gen bmi4 = rnormal()
gen bmi6 = rnormal()
gen bmi8 = rnormal()
gen gluc = 1+.3*bmi0-.2*bmi4-.1*bmi6+.5*bmi8+rnormal(0,10)
la var gluc "2-h glucose concentration"
la var bmi0 "BMI at birth"
la var bmi4 "BMI at age 4"
la var bmi6 "BMI at age 6"
la var bmi8 "BMI at age 8"
reshape long bmi, i(personid) j(age)
qui parmby "regr gluc bmi",by(age) saving(myfile, replace)
u myfile, clear
keep if parm=="bmi"
l age estimate min95 max95 p, sepby(age) noo

eclplot estimate min95 max95 age, /* */ eplottype(scatter)
rplottype(rcap) /* */ supby(parm ,) estopts( sort ) ciopts( ) 
*************
Martin Weiss wrote:
<> You are more than welcome! 

For the y-line, just add
*************
yline(0, lpattern(dash_dot) style(default) )
*************
to the -eclplot- call. Change the pattern according to your taste (-help
linepatternstyle-)...

Miranda Kim

Thank you so much Martin, this looks fantastic!
I had never used either parmest or eclplot!
Do you know how I could add a horizontal dotted line at zero?


Martin Weiss wrote:
 
Here is a solution employing -ssc d parmest- and -reshape-

*************
clear*
set obs 10000
//get Roger`s -parmest- 
capt which parmest
if _rc ssc inst parmest
gen personid=_n 
gen bmi0 = rnormal()
gen bmi4 = rnormal()
gen bmi6 = rnormal()
gen bmi8 = rnormal()
gen gluc = 1+.3*bmi0-.2*bmi4-.1*bmi6+.5*bmi8+rnormal(0,10)
la var gluc "2-h glucose concentration"
la var bmi0 "BMI at birth"
la var bmi4 "BMI at age 4"
la var bmi6 "BMI at age 6"
la var bmi8 "BMI at age 8"
reshape long bmi, i(personid) j(age)
qui parmby "regr gluc bmi",by(age) saving(myfile, replace)
u myfile, clear
keep if parm=="bmi"
l age estimate min95 max95 p, sepby(age) noo

eclplot estimate min95 max95 age, /* */ eplottype(scatter)
rplottype(rcap) /* */ supby(parm ,) estopts( sort ) ciopts( ) 
*************
 

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index