clear use z:documents/teach/datasets/salary drop if year != 95 * Problem 1c regress salary female i.degree i.field admin yrdeg startyr, robust * Problem 1d g yrdegsqr= yrdeg^2 g startyrsqr= startyr^2 regress salary female i.degree i.field admin yrdeg yrdegsqr startyr startyrsqr, robust test yrdegsqr startyrsqr * Problem 1e egen ctgyrdeg= cut(yrdeg), at(0 60 65 70 75 80 85 90 99) egen ctgstartyr= cut(startyr), at(0 60 65 70 75 80 85 90 99) regress salary female i.degree i.field admin i.ctgyrdeg i.ctgstartyr, robust regress salary female i.degree i.field admin yrdeg startyr i.ctgyrdeg i.ctgstartyr, robust testparm i.ctgyrdeg* testparm i.ctgstartyr* testparm i.ctgyrdeg* i.ctgstartyr* * Problem 1f mkspline yrdeg1 60 yrdeg2 65 yrdeg3 70 yrdeg4 75 yrdeg5 80 yrdeg6 85 yrdeg7 90 yrdeg8 = yrdeg mkspline startyr1 60 startyr2 65 startyr3 70 startyr4 75 startyr5 80 startyr6 85 startyr7 90 startyr8 = startyr regress salary female i.degree i.field admin yrdeg1-yrdeg8 startyr1-startyr8, robust test yrdeg1=yrdeg2=yrdeg3=yrdeg4=yrdeg5=yrdeg6=yrdeg7=yrdeg8 test startyr1=startyr2=startyr3=startyr4=startyr5=startyr6=startyr7=startyr8 test yrdeg1=yrdeg2=yrdeg3=yrdeg4=yrdeg5=yrdeg6=yrdeg7=yrdeg8, accum regress salary female i.degree i.field admin yrdeg1-yrdeg8 startyr1-startyr8 /// i.ctgyrdeg i.ctgstartyr, robust testparm yrdeg* testparm startyr* testparm yrdeg* startyr* testparm i.ctgy* testparm i.ctgs* testparm i.ctg* * Problem 1c poisson poisson salary female i.degree i.field admin yrdeg startyr, robust irr * Problem 1d poisson poisson salary female i.degree i.field admin yrdeg yrdegsqr startyr startyrsqr, robust irr test yrdegsqr startyrsqr * Problem 1e poisson poisson salary female i.degree i.field admin i.ctgyrdeg i.ctgstartyr, robust irr poisson salary female i.degree i.field admin yrdeg startyr i.ctgyrdeg i.ctgstartyr, robust irr testparm i.ctgyrdeg* testparm i.ctgstartyr* testparm i.ctgyrdeg* i.ctgstartyr* * Problem 1f poisson poisson salary female i.degree i.field admin yrdeg1-yrdeg8 startyr1-startyr8, robust irr test yrdeg1=yrdeg2=yrdeg3=yrdeg4=yrdeg5=yrdeg6=yrdeg7=yrdeg8 test startyr1=startyr2=startyr3=startyr4=startyr5=startyr6=startyr7=startyr8 test yrdeg1=yrdeg2=yrdeg3=yrdeg4=yrdeg5=yrdeg6=yrdeg7=yrdeg8, accum poisson salary female i.degree i.field admin yrdeg1-yrdeg8 startyr1-startyr8 /// i.ctgyrdeg i.ctgstartyr, robust irr testparm yrdeg* testparm startyr* testparm yrdeg* startyr* testparm i.ctgy* testparm i.ctgs* testparm i.ctg* * Problem 1c glm glm salary female i.degree i.field admin yrdeg startyr, robust link(log) eform * Problem 1d glm glm salary female i.degree i.field admin yrdeg yrdegsqr startyr startyrsqr, robust link(log) eform test yrdegsqr startyrsqr * Problem 1e glm glm salary female i.degree i.field admin i.ctgyrdeg i.ctgstartyr, robust link(log) eform glm salary female i.degree i.field admin yrdeg startyr i.ctgyrdeg i.ctgstartyr, robust link(log) eform testparm i.ctgyrdeg* testparm i.ctgstartyr* testparm i.ctgyrdeg* i.ctgstartyr* * Problem 1f glm glm salary female i.degree i.field admin yrdeg1-yrdeg8 startyr1-startyr8, robust link(log) eform test yrdeg1=yrdeg2=yrdeg3=yrdeg4=yrdeg5=yrdeg6=yrdeg7=yrdeg8 test startyr1=startyr2=startyr3=startyr4=startyr5=startyr6=startyr7=startyr8 test yrdeg1=yrdeg2=yrdeg3=yrdeg4=yrdeg5=yrdeg6=yrdeg7=yrdeg8, accum glm salary female i.degree i.field admin yrdeg1-yrdeg8 startyr1-startyr8 /// i.ctgyrdeg i.ctgstartyr, robust link(log) eform testparm yrdeg* testparm startyr* testparm yrdeg* startyr* testparm i.ctgy* testparm i.ctgs* testparm i.ctg* * Problem 1c geom mean g logslry= log(salary) regress logslry female i.degree i.field admin yrdeg startyr, robust * Problem 1d geom mean regress logslry female i.degree i.field admin yrdeg yrdegsqr startyr startyrsqr, robust test yrdegsqr startyrsqr * Problem 1e geom mean regress logslry female i.degree i.field admin i.ctgyrdeg i.ctgstartyr, robust regress logslry female i.degree i.field admin yrdeg startyr i.ctgyrdeg i.ctgstartyr, robust testparm i.ctgyrdeg* testparm i.ctgstartyr* testparm i.ctgyrdeg* i.ctgstartyr* * Problem 1f geom mean regress logslry female i.degree i.field admin yrdeg1-yrdeg8 startyr1-startyr8, robust test yrdeg1=yrdeg2=yrdeg3=yrdeg4=yrdeg5=yrdeg6=yrdeg7=yrdeg8 test startyr1=startyr2=startyr3=startyr4=startyr5=startyr6=startyr7=startyr8 test yrdeg1=yrdeg2=yrdeg3=yrdeg4=yrdeg5=yrdeg6=yrdeg7=yrdeg8, accum regress logslry female i.degree i.field admin yrdeg1-yrdeg8 startyr1-startyr8 /// i.ctgyrdeg i.ctgstartyr, robust testparm yrdeg* testparm startyr* testparm yrdeg* startyr* testparm i.ctgy* testparm i.ctgs* testparm i.ctg* * Problem 2a regress salary female i.degree i.field admin yrdeg, robust * Problem 2b regress salary female i.degree i.field admin startyr, robust * Problem 2c (and 2d) regress salary female i.degree i.field admin yrdeg startyr, robust * Problem 3 regress salary female, robust regress salary female i.degree, robust regress salary female i.degree yrdeg1-yrdeg8, robust regress salary female i.degree yrdeg1-yrdeg8 startyr1-startyr8, robust regress salary female i.degree yrdeg1-yrdeg8 startyr1-startyr8 i.field, robust regress salary female i.degree yrdeg1-yrdeg8 startyr1-startyr8 i.field admin, robust predict fit3 regress salary female i.degree yrdeg1-yrdeg8 startyr1-startyr8 i.field admin i.rank, robust * Problem 4 regress logslry female, robust regress logslry female i.degree, robust regress logslry female i.degree yrdeg1-yrdeg8, robust regress logslry female i.degree yrdeg1-yrdeg8 startyr1-startyr8, robust regress logslry female i.degree yrdeg1-yrdeg8 startyr1-startyr8 i.field, robust regress logslry female i.degree yrdeg1-yrdeg8 startyr1-startyr8 i.field admin, robust predict fit4 replace fit4= exp(fit4) regress logslry female i.degree yrdeg1-yrdeg8 startyr1-startyr8 i.field admin i.rank, robust * Problem 5 poisson salary female, robust irr poisson salary female i.degree, robust irr poisson salary female i.degree yrdeg1-yrdeg8, robust irr poisson salary female i.degree yrdeg1-yrdeg8 startyr1-startyr8, robust irr poisson salary female i.degree yrdeg1-yrdeg8 startyr1-startyr8 i.field, robust irr poisson salary female i.degree yrdeg1-yrdeg8 startyr1-startyr8 i.field admin, robust irr predict fit5a poisson salary female i.degree yrdeg1-yrdeg8 startyr1-startyr8 i.field admin i.rank, robust irr glm salary female, robust link(log) eform glm salary female i.degree, robust link(log) eform glm salary female i.degree yrdeg1-yrdeg8, robust link(log) eform glm salary female i.degree yrdeg1-yrdeg8 startyr1-startyr8, robust link(log) eform glm salary female i.degree yrdeg1-yrdeg8 startyr1-startyr8 i.field, robust link(log) eform glm salary female i.degree yrdeg1-yrdeg8 startyr1-startyr8 i.field admin, robust link(log) eform predict fit5b glm salary female i.degree yrdeg1-yrdeg8 startyr1-startyr8 i.field admin i.rank, robust link(log) eform scatter fit4 fit3, xtitle("Fitted Values: Inference on Difference in Means") /// ytitle("Fitted Values: Inference on Geometric Mean Ratios") /// t1("Comparison of Fitted Values Problem 4 vs Problem 3") scatter fit5a fit3, xtitle("Fitted Values: Inference on Difference in Means") /// ytitle("Fitted Values: Inference on Mean Ratios (Poisson)") /// t1("Comparison of Fitted Values Problem 5 (Poisson) vs Problem 3") scatter fit5b fit3, xtitle("Fitted Values: Inference on Difference in Means") /// ytitle("Fitted Values: Inference on Mean Ratios (GLM)") /// t1("Comparison of Fitted Values Problem 5 (GLM) vs Problem 3") scatter fit5b fit5a, xtitle("Fitted Values: Inference on Mean Ratios (Poisson)") /// ytitle("Fitted Values: Inference on Mean Ratios (GLM)") /// t1("Comparison of Fitted Values Problem 5: GLM vs Poisson")