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]

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


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: FW: st: Plotting several linear associations in one graph for comparison
Date   Mon, 16 Jul 2012 12:33:37 +0200

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/


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