capture log close log using gcpaper02-model1-tab2-fig45, replace text // program: gcpaper02-model1-tab2-fig45.do // task: model 1: table 2 & figures 4 & 5 // group and articles only // project: Group comparisons in logit and probit // using predicted probabilities // author: jsl \ 2009-05-27 // #0 // program setup version 10 clear all set linesize 80 matrix drop _all set scheme s2manual local pgm "gcpaper02" local dte "2009-05-26" // #1 // load the tenure data use gc_tenure01, clear datasignature confirm keep if allisonsmr // use allison sample // #2 // Table 2 - Model 1: tenure on articles by gender // #2a - matrix for table 2 local nrows = 4 matrix table2 = J(`nrows',6,.) matrix colnames table2 = Wb Wexpb Wz Mb Mexpb Mz matrix rownames table2 = Contant articles Log-likelihood N // #2b - create table 2 * for women logit tenure articles if female==1, nolog mat Mb = e(b) mat MV = e(V) mat table2[1,1] = Mb[1,2] // constant mat table2[2,1] = Mb[1,1] // b-articles mat table2[2,2] = exp(Mb[1,1]) // or-articles mat table2[1,3] = Mb[1,2]/sqrt(MV[2,2]) // z-test mat table2[2,3] = Mb[1,1]/sqrt(MV[1,1]) mat table2[3,1] = e(ll) // LL mat table2[4,1] = e(N) // N * for men logit tenure articles if female==0, nolog mat Mb = e(b) mat MV = e(V) mat table2[1,4] = Mb[1,2] // constant mat table2[2,4] = Mb[1,1] // b-articles mat table2[2,5] = exp(Mb[1,1]) // or-articles mat table2[1,6] = Mb[1,2]/sqrt(MV[2,2]) // z-test mat table2[2,6] = Mb[1,1]/sqrt(MV[1,1]) mat table2[3,4] = e(ll) // LL mat table2[4,4] = e(N) // N // #2c - print table 2 mat list table2, format(%9.3f) // #3 // Model 1 using gcsetup and gcmodel // #3a - gcsetup & gcmodel gcsetup articles, details grpvar(male) /// gr0var(f0) gr0label(women) gr1var(m1) gr1label(men) gcmodel articles, label(M1_articles) details // #3b - estimate interactive model using global rhsinteract logit tenure $rhsinteract, nocon nolog // #3c // z-test for predictions at articles at 15 *gcprvalue, x(articles=15) matrix(model1) print reset gcprvalue, x(articles=15) matrix(model1) label(M1_art_15) gcprvalue, x(articles=7) matrix(model1) print label(M1_art_7) /* verification using prvalues qui prvalue, x(f0=0 f0art= 0 m1=1 m1art=15) lab(Men15) save prvalue, x(f0=1 f0art=15 m1=0 m1art= 0) lab(Women15) dif mat list r(pred) */ // #4 // Figures 4 & 5 - Model 1 // #4a // plot options * lines for men and women local optlinbwM "clpat(solid) clwid(medium) clcol(black)" local optlinbwF "clpat(dash) clwid(medium) clcol(black)" * symbols - invisible local optnosym "msymbol(i) mcol(none)" * line widths local optylin "lwid(medium) lcol(black)" * grid type local optygrid "grid glcol(black) glwid(medium) glpattern(dot)" * legend location local optlegend "pos(11) order(2 1) ring(0) cols(1) region(ls(none))" // #4b // Figure 4 - Model 1 - plot of probabilities // generate items to plot gcprgen articles, from(0) to(50) gap(2) gen(m1) // plot probabilties local title "Figure 4 for Model 1: articles and gender" local title " " label var m1Value "Number of Articles" label var m1men "Men" label var m1women "Women" label var m1Diff "Male-Female difference" label var m1Lower "95% confidence interval" label var m1Upper "95% confidence interval" local pltfil "`pgm'_F4_M1_prob.png" local plttag "`pgm'.do jsl `dte'" local caption "Source: `pltfil' from `plttag', size(tiny)" twoway /// (connected m1women m1Value, `optlinbwF' `optnosym') /// (connected m1men m1Value, `optlinbwM' `optnosym') /// , caption(`caption') /// legend(`optlegend') title(`title',size(medium)) /// ytitle(Pr(tenure)) ylabel(0(.2)1.,`optygrid') yline(0 1, `optylin') /// xlabel(0(10)50) graph export `pltfil', replace width(1200) // #4c // Figure 5 - Model 1 - plot of discrete changes local title "Figure 5 for Model 1: articles and gender" local title " " local optlegend "pos(11) order(2 1) ring(0) cols(1) region(ls(none))" local pltfil "`pgm'_F5_M1_dc.png" local plttag "`pgm'.do jsl `dte'" local caption "Source: `pltfil' from `plttag', size(tiny)" twoway (rarea m1Upper m1Lower m1Value, color(gs14)) /// (connected m1Diff m1Value, `optnosym' `optlinDC' ) /// , caption(`caption') /// legend(`optlegend') title(`title', size(medium)) /// ytitle(Pr( tenure | men )-Pr( tenure | women )) ylabel(0(.2)1) graph export `pltfil', replace width(1200) log close exit