capture log close log using icda02a-binary-rev, replace text // program: icda02a-binary-rev.do // task: Review 2 - Binary Regression // project: ICPSR CDA // author: your name \ today's date // #1 // program setup version 10 clear all set linesize 80 matrix drop _all // #2 // Load data use icpsr_scireview3, clear // #3 // Examine data, select variables, drop missing, and verify describe keep faculty fellow phd mcit3 mnas misschk dropmiss, obs summarize tab1 faculty fellow phd mcit mnas // #4 // Binary logit model logit faculty fellow phd mcit3 mnas // #5 // Store the results eststo estlogit // #6 // Predicted probabilities predict prlogit label var prlogit "Logit: Predicted Probability" sum prlogit dotplot prlogit graph export icda02a-binary-rev-fig1.emf , replace // #7 // Predict specific probabilities prvalue , x(fellow=1 mnas=1) rest(mean) // #8 // Table of predicted probabilities prtab fellow mnas // #9 // discrete change 1 quietly prvalue , x(fellow=1) rest(mean) save label(Fellow) prvalue , x(fellow=0) rest(mean) dif label(NotFellow) // #10 // discrete change 2 prchange, rest(mean) help // #11 // Plot predicted probabilities prgen mcit3, x(fellow=1) rest(mean) from(0) to(130) gen(fel1) gap(5) ci prgen mcit3, x(fellow=0) rest(mean) from(0) to(130) gen(fel0) gap(5) ci label var fel1p1 "Fellow" label var fel0p1 "Not a Fellow" graph twoway /// (rarea fel1p1ub fel1p1lb fel1x, color(gs10)) /// (rarea fel0p1ub fel0p1lb fel0x, color(gs10)) /// (connected fel1p1 fel1x, lpattern(dash) msize(zero)) /// (connected fel0p1 fel1x, lpattern(solid) msize(zero)), /// legend(on order(3 4)) /// ylabel(0(.25)1) ytitle("Pr(Faculty)") /// xlabel(0(10)130) xtitle("Mentor's # of Citations") /// title("Predicted Probability of Having a Faculty Position") graph export icda02a-binary-rev-fig2.emf , replace // #12 // Odds ratios listcoef, help // #13 // Compare to probit probit faculty fellow phd mcit3 mnas eststo estprobit esttab estlogit estprobit , mtitles(logit probit) // #14 // Close log file & exit do-file log close exit