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]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: FW: st: Plotting several linear associations in one graph for comparison |

Date |
Mon, 16 Jul 2012 11:25:48 +0100 |

You said you didn't understand the -replace- statements. The -replace- statements re-set particular variables to constants for use in the model equation by -predict-. This appears to be exactly what you are asking for. Neither Maarten nor anybody else can tell you what your code should be as you give no real details of exactly what your model(s) is or are, or of your data. So, the best kind of answer you can expect is what Maarten did: Give you an example for what appears to be a similar problem. Nick On Mon, Jul 16, 2012 at 11:12 AM, Amal Khanolkar <Amal.Khanolkar@ki.se> wrote: > Regarding my previous question: plotting multiple linear regressions stratified by a particular variable on the same graph. I received some example syntax from Maarten but I was unable to understand the details. > > Does anybody else have any ideas on how twoway line plot can be exploited for my prupose? > > My original Q: > > - I've run some very basic and simple linear regression models to analyse associations between standardized birth weight and blood pressure, adjusting for confounders like birth year, current age, BMI, height etc. >> >> - The associations between birth weight and blood pressure are stratified by ethnicity (12 ethnic goups - thus 12 separate linear regression models). I see that the association between birth weight and blood pressure does differ in the various ethnic goups. >> >> - I would now like to plot the above associations in a single graph using different colours for the various ethnic groups for comparison. From: Amal Khanolkar > > Thanks for your example. > > Just wondering what the 'replace' commands are doing specifically? I guess it's not important for me. > > Ideally, I ran my regressions stratifying by race, (if race==1 and so on) - should I also predict yhat separately for each racial group as well? Maarten Buis [maartenlbuis@gmail.com] > On Fri, Jul 13, 2012 at 2:42 PM, Amal Khanolkar wrote: >> - I've run some very basic and simple linear regression models to analyse associations between standardized birth weight and blood pressure, adjusting for confounders like birth year, current age, BMI, height etc. >> >> - The associations between birth weight and blood pressure are stratified by ethnicity (12 ethnic goups - thus 12 separate linear regression models). I see that the association between birth weight and blood pressure does differ in the various ethnic goups. >> >> - I would now like to plot the above associations in a single graph using different colours for the various ethnic groups for comparison. > > *---------------- begin example ---------------- > sysuse nlsw88, clear > reg wage i.race##c.grade i.union hours ttl_exp > preserve > replace union = 1 > replace hours = 40 > replace ttl_exp = 15 > bys race grade : keep if _n == 1 > predict yhat > separate yhat, by(race) > twoway line yhat1 yhat2 yhat3 grade > restore > *--------------- end example ------------------- > (For more on examples I sent to the Statalist see: > http://www.maartenbuis.nl/example_faq ) > * * 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/

**References**:**st: Plotting several linear associations in one graph for comparison***From:*Amal Khanolkar <Amal.Khanolkar@ki.se>

**Re: st: Plotting several linear associations in one graph for comparison***From:*Maarten Buis <maartenlbuis@gmail.com>

**RE: st: Plotting several linear associations in one graph for comparison***From:*Amal Khanolkar <Amal.Khanolkar@ki.se>

**FW: st: Plotting several linear associations in one graph for comparison***From:*Amal Khanolkar <Amal.Khanolkar@ki.se>

- Prev by Date:
**FW: st: Plotting several linear associations in one graph for comparison** - Next by Date:
**Re: graphing results from multilevel model [Was: Re: st: Thread-index: AQHNYz]** - Previous by thread:
**Re: FW: st: Plotting several linear associations in one graph for comparison** - Next by thread:
**st: separate text boxes in each panel of a "by"** - Index(es):