/*----------------------------------------------------------- Binary Dependent Variable Example Public Transportation by income level y =1 if take public transportation =0 otherwise income Income (in $1,000) gender =1 if male = 0 if female distance Commute Distance in miles ------------------------------------------------------------*/ clear all use https://bigblue.depaul.edu/jlee141/econdata/eco304/binary_transp.dta /* Linear Probability Model */ regr y income predict ylpm, resid gen y_dec = 0 replace y_dec = 1 if ylpm > 0.5 tab y y_dec /* Heteroskedasticity */ estat hettest imtest,white /* Prediction for out of boundary check */ predict yhat label var yhat "yhat from LPM" twoway (scatter (y yhat) income) /* Logistic Model */ /* Logistic Model with income */ logit y income mfx mfx, at(50) mfx, at(100) predict yhat_logit label var yhat_logit "yhat from Logit P(x)" gen y_logdec = 0 replace y_logdec = 1 if yhat_logit > 0.5 tab y y_logdec twoway (scatter (y yhat_logit) income) (line yhat income) /* Logistic Model with income gender distance */ logit y income gender distance mfx mfx, at(50 0 5) mfx, at(100 1 5) predict yhat_logit2 label var yhat_logit2 "yhat from Logit P(x)" gen y_logdec2 = 0 replace y_logdec2 = 1 if yhat_logit2 > 0.5 tab y y_logdec2 twoway (scatter (y yhat_logit) income) (scatter yhat_logit2 income)