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 |
Amal Khanolkar <Amal.Khanolkar@ki.se> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

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

Date |
Mon, 16 Jul 2012 13:10:43 +0000 |

Thank you Maarten, I understand a lot better now. Just one last question: how did you 'fix' the covariates, i.e how did you choose the 1, 40 & 15 in your example below? // the correct graph (again) 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 Thanks, /Amal. ________________________________________ From: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] on behalf of Maarten Buis [maartenlbuis@gmail.com] Sent: 16 July 2012 12:33 To: statalist@hsphsun2.harvard.edu Subject: Re: FW: st: Plotting several linear associations in one graph for comparison On Mon, Jul 16, 2012 at 12:12 PM, Amal Khanolkar wrote: > Just wondering what the 'replace' commands are doing specifically? I guess it's not important for me. It is very important, also for you. The logic is that you want to predicted outcome. -predict- has to use the values of all covariates in order to do the predicting. If you do not fix the values of the covariates (i.e. use -replace-) you will end up with modern art rather than an interpretable graph. > 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? Yes, you will have to use different names, and take care that you do not extrapolate to the other races. In that case you no longer have to use -separate-. *---------------- begin example ---------------- sysuse nlsw88, clear reg wage i.race##c.grade i.union hours ttl_exp // what happens when you do not fix covariates predict yhat_wrong separate yhat_wrong, by(race) twoway line yhat_wrong1 yhat_wrong2 yhat_wrong3 grade, sort // the correct graph (again) 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 // doing it separately, notice that this is *not* // equivalent to the example above drop yhat* reg wage grade union hours ttl_exp if race == 1 est store white reg wage grade union hours ttl_exp if race == 2 est store black reg wage grade union hours ttl_exp if race == 3 est store other preserve replace union = 1 replace hours = 40 replace ttl_exp = 15 bys race grade : keep if _n == 1 est restore white predict yhat1 if race == 1 est restore black predict yhat2 if race == 2 est restore other predict yhat3 if race == 3 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 ) -------------------------- Maarten L. Buis Institut fuer Soziologie Universitaet Tuebingen Wilhelmstrasse 36 72074 Tuebingen Germany http://www.maartenbuis.nl -------------------------- * * 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/ * * 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/

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

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

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

- Prev by Date:
**Re: st: Value label gaps** - Next by Date:
**Re: st: Value label gaps** - Previous by thread:
**Re: FW: st: Plotting several linear associations in one graph for comparison** - Next by thread:
**Re: FW: st: Plotting several linear associations in one graph for comparison** - Index(es):