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: Plotting regression coefficients


From   Miranda Kim <[email protected]>
To   <[email protected]>
Subject   st: Re: Plotting regression coefficients
Date   Wed, 2 Jun 2010 12:47:50 +0100

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-)...

HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Miranda Kim
Gesendet: Mittwoch, 20. Januar 2010 10:56
An: [email protected]
Betreff: Re: AW: st: AW: Plotting regression coefficients
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?
Best wishes,
Miranda
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( ) 
*************
 
HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Martin Weiss
Gesendet: Mittwoch, 20. Januar 2010 10:35
An: [email protected]
Betreff: AW: st: AW: Plotting regression coefficients
 
<> 
Sounds like a case for a -reshape long- to me, before you even
-regress-...

HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Miranda Kim
Gesendet: Mittwoch, 20. Januar 2010 10:26
An: [email protected]
Betreff: Re: st: AW: Plotting regression coefficients
Thank you Martin, Alan and Nick for your replies,
I'm sorry I didn't give enough description of my dataset. As it is currently structured I have each line (observation) corresponding to a distinct person. I have five variables for each individual (five columns in my dataset): 
gluc = 2-h glucose concentration
bmi0 = BMI at birth
bmi4 = BMI at age 4
bmi6 = BMI at age 6
bmi8 = BMI at age 8
I could simply type
reg gluc bmi0
reg gluc bmi4
etc.
saving the regression coefficients (and CIs) along the way, and then plotting them. 
But I didn't know if this was a long-winded way of going about it.
Many thanks
Miranda
Blood glucose vs. BMI at birth
Blood glucose vs. BMI at age 4
Blood glucose vs. BMI at age 6
Blood glucose vs. BMI at age 8
 
Martin Weiss wrote:
<> 
Apart from -statsby-, -ssc d parmest- by Roger Newson may be useful for
you...
 
HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Miranda Kim
Gesendet: Dienstag, 19. Januar 2010 18:03
An: [email protected]
Betreff: st: Plotting regression coefficients
I am using Stata v11

I would like to run four regressions of the same outcome variable on a given predictor at four different timepoints. For example: 
Blood glucose vs. BMI at birth
Blood glucose vs. BMI at age 4
Blood glucose vs. BMI at age 6
Blood glucose vs. BMI at age 8

Then I would like to plot the four regression coefficients and respective confidence intervals on the same graph, with time as the 
x-axis.
I wonder what the most straightforward way of producing such a plot would be. 
Any suggestions would be of great help.
Many thanks,
Miranda

*
*   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/ 		 	   		  
_________________________________________________________________
http://clk.atdmt.com/UKM/go/195013117/direct/01/
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now
*
*   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