--- David Airey <[email protected]> wrote:
> I don't see where yhat1 and yhat2 are created in your example here.
Good catch, I was doubting whether to add the linear spline to the
graph as well, in the end decided to compromise: don't create the
variable but do add it to the graph (ahem). Below is an example that
actually works.
Thanks,
Maarten
*--------------------- begin example ------------------------
sysuse nlsw88, clear
gen ln_w = ln(wage)
gen black = race == 2 if race < .
mkspline ten1 10 ten2 = tenure
reg ln_w ten1 ten2 union age black collgrad
est store a
mkspline tens=tenure, cubic nk(3)
reg ln_w tens* union age black collgrad
preserve
sum age if e(sample)
replace age = r(mean)
replace union = 1
replace black = 0
replace collgrad = 1
predict yhat2
est restore a
predict yhat1
bys tenure: gen byte mark = _n== 1
twoway line yhat1 yhat2 tenure if mark, ///
sort lpattern(shortdash dash) ///
legend(order( 1 "linear spline" ///
2 "restricted" ///
"cubic spline" )) ///
ytitle("predicted income")
restore
*-------------------- end example -----------------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
__________________________________________________________
Sent from Yahoo! Mail.
The World's Favourite Email http://uk.docs.yahoo.com/nowyoucan.html
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/