// Task 1 routine setup capture log close set more off estimates clear log using cda05c-ex5done.log, replace text version 9.2 set scheme s2mono // pgm: cda05c-ex5done.do // task: 5 - Testing and Assessing Fit - Excercise // project: CDA Lab Guide // author: your name // date: today's date use sci-review, clear // Task 2: keep stjob, female, enrol, and phd. Explore and drop missing. // Step 2.1 keep the four variables and explore. keep stjob female enrol phd tab1 _all, missing sum // Step 2.2 drop missing cases mark nomiss markout nomiss _all tab nomiss keep if nomiss==1 drop nomiss // Step 2.3 verify the last step sum // Task 3: Test that being female does not affect stjob in full model. // Task 3a: estimate full model and use z-statistics logit stjob female enrol phd, nolog estimates store base /* Type your answer here 1) Being female does not affect the prestige of first job at .05 level. 2) The effect of being female is not significant at the .05 level for a two-tailed test. */ // Task 3b: use test to test the effect of being female. test female /* Type your answer here z-squaree = chi-square with df=1 */ // Task 3c: test the same hypothesis using an LR test logit stjob enrol phd estimates store dropfemale lrtest dropfemale base // Task 4: Test that the effects of female and enroll are simultaneously // equal to zero using a Wald test and an LR test. // Task 4a: the wald test logit stjob female enrol phd, nolog estimates store base // used for the lrtest command in 3.2 test female enrol // Task 4b: the LR test logit stjob phd estimates store dropfemaleenrol lrtest dropfemaleenrol base // Task 4c: compare the estiamtes estimates dir estimates table base dropfemale dropfemaleenrol, b(%8.3f) t(%8.3f) /// stats(N ll chi2 df_m bic aic) // Task 5: Test that the effect of enroll equals that of phd. // Step 5.1: estimate full model and use test. logit stjob female enrol phd test enrol=phd /* Type your answer here We can reject the hypothesis that the effects of Ph.D. prestige and years of enrollment are equal (p<.01). */ // Task 6: Use fitstat to compare the full model with the // model with female and the model without female or enrol. // Step 6.1 run a logit regression of stjob on female, enrol, and phd // and use fitstat, saving the results. logit stjob female enrol phd, nolog fitstat, saving(mod1) // Step 6.2 run a second logit regression of stjob on enrol and phd; // use fitstat with saving() and using() to compare models. logit stjob enrol phd, nolog fitstat, saving(mod2) using(mod1) // Step 6.3 run a third logit regression of stjob on female and compare. logit stjob female, nolog fitstat, using(mod1) fitstat, using(mod2) // Task 7: Use methods of outlier detection to examine weaknesses in // your model. * residuals logit stjob female enrol phd, nolog predict mod1rstd, rs label var mod1rstd "Standardized Residual" sort phd, stable generate index = _n label var index "Observation Number" * graph twoway scatter mod1rstd index, msymbol(Oh) mcolor(black) /// * xtitle("Observation Number") xlabel(0(100)150) /// * ylabel(-4(2)4) yline(0, lpattern(solid)) /// * yline(2 -2, lpattern(dot)) graph twoway scatter mod1rstd index, msymbol(none) /// mlabel(index) mlabsize(small) mlabposition(0) /// xtitle("Observation Number") xlabel(0(100)150) /// ylabel(-4(2)4) yline(0, lpattern(solid)) /// yline(2 -2, lpattern(dot)) graph export cda05c-ex5-fig1.emf, replace sort mod1rstd list mod1rstd female enrol phd index if mod1rstd>1.75 | mod1rstd<-1.75 * influence predict mod1cook, dbeta label var mod1cook "Cook's Statistic" sort index graph twoway scatter mod1cook index, /// mlabel(index) msymbol(none) mlabposition(0) /// xtitle("Observation Number") xlabel(0(100)150) /// ylabel(0(.1).3) yline(.1 .2, lpattern(dot)) graph export cda05c-ex5-fig2.emf, replace list mod1cook mod1rstd female enrol phd index if mod1cook>.2 log close exit