** COMMENT Dummy Dependent Variable Heteroskedasticity & Logistic Regression log using x:\Logit_example_out.log, replace infix age 5-6 ed 7-8 race 14 south16 15 bwlaw 24 class10 29-30 memnum 31-32 contact 49 /// using "s:\703 Kaufman\bwmarry." if race==1 gen class= 11-class10 global ivars = "age ed south16 class contact" summarize bwlaw $ivars ** COMMENT Run OLS Then Show its Problems regress bwlaw $ivars predict resbw, res predict predbw, xb gen ressq= (resbw/e(rmse))^2 gen vary= predbw*(1-predbw) ** COMMENT Heteroskedasticity: Plots, Mean Squared Residual, Out-of-range Prediction scatter ressq age, name(age) scatter ressq ed, name(ed) scatter ressq class, name(subj_class) scatter ressq contact, name(contact) scatter ressq predbw, name(predbw) scatter resbw age, yline(0)name(res_age) scatter resbw ed, yline(0)name(res_ed) gen predcat=round(predbw/.1) replace predcat=-1 if predbw<0 replace predcat=11 if predbw>=1 table predcat, content(mean ressq mean vary n vary) ** COMMENT Run Logistic Regression, calculate Goodness-of-fit, P-ref choices logit bwlaw $ivars goflogit bwlaw quietly adjust $ivars, pr gen(holdpr) scalar predy=holdpr[1] quietly summ bwlaw scalar meany=r(mean) ** COMMENT Get Auxiliary Unstandardized & Semi-standardized Coeffs at various P-ref logitstand meany logitstand predy logitstand .1 logitstand .2 logitstand .3 logitstand .4 logitstand .5 ** COMMENT Creating P_ref for Interesting Cases ** Case1: Old (65) High School (12) South (1) Lower-mid Class (3) No Contact (0) ** Case2: Young (25) College (16) Nonsouth (0) Upper-mid Class (7) High Cont (3) adjust age=65 ed=12 south16=1 class=3 contact=0,pr gen(p1var) nokey scalar p1=p1var[1] adjust age=25 ed=16 south16=0 class=7 contact=3,pr gen(p2var) nokey scalar p2=p2var[1] drop p1var p2var ** COMMENT Auxiliary Coefficients for Last Model with New P_ref values logitstand p1 logitstand p2 ** COMMENT Test Adding a Predictor to the Model logit bwlaw $ivars memnum ** COMMENT Run Probit Analysis for Comparison probit bwlaw $ivars ** COMMENT Clear Data from Memory clear ** COMMENT Example of Multinomial Logit of Political Ideology on Age Ed Sex Attend infix grass 1 age 2-3 ed 4-5 sex 6 size 7-10 polscale 11 attend 12 pray 13 /// using "s:\703 Kaufman\mlogtdat." recode polscale (1/3=1)(4=2)(5/7=3) , gen(pol) label define libcon 1 liberal 2 moderate 3 conservative label values pol libcon summ age ed sex attend pol polscale tab2 pol polscale mlogit pol age ed sex attend, base(1) ** COMMENT Change Base Comparison to Moderate to get Significance of Conservative : Moderate Contrast mlogit pol age ed sex attend, base(2)