Code:
test reg
use http://fmwww.bc.edu/RePEc/bocode/o/oaxaca.dta, clear
drop if lnwage==.
drop if exp(lnwage)>100
gen wage=exp(lnwage)
quietly sum exper, detail
local max=r(max)
sort wage
gen id=_n
expand 99
gen wage_hat=.
gen wage_stressed=.
bysort id:gen idq=_n
forvalues q=1/99{
local fq=`q'/100
qui:qreg wage educ exper tenure female if idq==1, q(`fq')
replace wage_stressed= _b[_cons] + _b[educ]*educ + _b[exper]*`max' + _b[tenure]*tenure + _b[female]*female if idq==`q'
capture drop aux
predict aux
replace wage_hat=aux if idq==`q
}
two kdensity wage if idq==1 || kdensity wage_hat || kdensity wage_stressed, legend(order(1 "original Wage distribution" 2 "Predicted Wage distribution" 3 "Stressed Wage distribution"))
Comment