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

st: Ignore dummy variable in predict function?

From   Dorothy Bridges <>
Subject   st: Ignore dummy variable in predict function?
Date   Mon, 9 Nov 2009 17:28:24 -0500

Dear Statalist:

I have a dataset in which my dependent variable -- say, life
expectancy, so I can use the uslifexp.dta file as an example -- is
measured according to two different methods.  In other words, life
expectancy is measured according to method a in some years and method
b in other years.  Method a always yields measures that are lower than
those generated with method b, though much lower varies by

I would like to identify the time trend in this data.  Hence I regress
the outcome variable on year and a dummy variable for the observations
generated with method a, a la:

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

Now I would like to generate predicted values of le, **as if** all of
the method-a observations had been created using method b.  In other
words: when I follow the regress command with "predict le_predict" and
then look at "twoway (scatter le_measure1 year) (lfit le_measure1
year) (line le_predict year)", I want the le_predict line (green) to
be straight.  It would be something like "predict le_predict as if
measuredummy==0," if such a command existed.

Thank you!!

D. Bridges
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index