Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Ignore dummy variable in predict function?


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Ignore dummy variable in predict function?
Date   Mon, 9 Nov 2009 14:45:43 -0800 (PST)

--- On Mon, 9/11/09, Dorothy Bridges wrote:
> Now I would like to generate predicted values of le, **as
> if** all of the method-a observations had been created using
> method b.  

*------------------ begin example --------------------
sysuse uslifeexp.dta, clear

**(Imitating my actual data)
gen le_measure1=.
replace le_measure1=le-5 if year<=1950 | year==1965 | year==1972 | /// 
year==1986 | year==1989
replace le_measure1=le if le_measure1==.

**The regression:
gen measuredummy=1
replace measuredummy=0 if le_measure1==le

regress le_measure1 year measuredummy

clonevar temp = measuredummy

replace measuredummy = 0
predict le0, xb

replace measuredummy = 1
predict le1, xb

replace measuredummy = temp
drop temp

twoway scatter le_measure1 year if measuredummy == 0 || ///
       scatter le_measure1 year if measuredummy == 1 || ///
       line le0 year                                 || ///
       line le1 year,                                   ///
       legend(order(1 "measure 0"                       ///
                    3 "measure 0"                       ///
                    - " "                               ///
                    2 "measure 1"                       ///
                    4 "measure 1" ))
*---------------------- end example -----------------------------

Hope this helps,
Maarten

--------------------------
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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index