/*----------------------------------------------------------- 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 eststo lpm predict y_lpm gen y_dec = 0 replace y_dec = 1 if y_lpm > 0.5 tab y y_dec /* Prediction for out of boundary check */ label var y_lpm "yhat from LPM" twoway (scatter (y y_lpm) income) /* Probit Model */ probit y income eststo probit predict y_probit twoway (scatter (y y_probit) income) /* Logistic Model */ /* Logistic Model with income */ logit y income eststo logit predict y_logit label var y_logit "yhat from Logit P(x)" gen y_logdec = 0 replace y_logdec = 1 if y_logit > 0.5 tab y y_logdec twoway (scatter (y y_logit) income) (line y_lpm income) /* Comparison of Three Models */ esttab lpm probit logit, r2 ar2 pr2 sca( ll_0 chi2 p) /* Prediction and Marginal Effects at given X */ qui: regr y income mfx mfx, at(50) mfx, at(100) qui: probit y income mfx mfx, at(50) mfx, at(100) qui: logit y income mfx mfx, at(50) mfx, at(100) /* Multivariate 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)