-----------------------------------------------------------------------------------------------
       log:  e:\analysis\stataboston\work\sug_groups_tenure.log
  log type:  text
 opened on:  20 Jul 2006, 09:48:06

. version 9.1

. 
. //  sug_groups_tenure.do - stata user's group - july 2006
. //  logit example of gender differences in tenure
. //  Scott Long - 20Jul2006
. 
. // #1
. //  descriptive statistics
. 
. spex tenure01, clear

. use "http://www.indiana.edu/~jslsoc/stata/spex_data/tenure01.dta", clear

. vardesc tenure female year yearsq select articles prestige presthi

Variable         Mean   StdDev  Minimum  Maximum  Label                  
tenure           0.12     0.33     0.00     1.00  Is tenured?            
female           0.38     0.49     0.00     1.00  Scientist is female?   
year             4.33     3.09     1.00    22.00  Years in rank.         
yearsq          28.29    44.18     1.00   484.00  Years in rank squared. 
select           4.97     1.43     1.00     7.00  Selectivity of bachelor's
articles         7.21     6.74     0.00    73.00  Total number of articles.
prestige         2.63     0.77     0.65     4.80  Prestige of department.
presthi          0.05     0.21     0.00     1.00  Prestige is 4 or higher?

N = 2945

. 
. // #2
. //  estimation
. 
. logit tenure female year yearsq select articles presthi, nolog

Logistic regression                               Number of obs   =       2945
                                                  LR chi2(6)      =     336.43
                                                  Prob > chi2     =     0.0000
Log likelihood = -931.36045                       Pseudo R2       =     0.1530

------------------------------------------------------------------------------
      tenure |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      female |  -.3735409   .1270093    -2.94   0.003    -.6224745   -.1246073
        year |    .932456    .084743    11.00   0.000     .7663627    1.098549
      yearsq |  -.0538009   .0060204    -8.94   0.000    -.0656007   -.0420011
      select |   .1231439   .0428113     2.88   0.004     .0392353    .2070525
    articles |   .0509106   .0077581     6.56   0.000     .0357049    .0661163
     presthi |  -.9444709    .369606    -2.56   0.011    -1.668885   -.2200565
       _cons |  -5.770548   .3523052   -16.38   0.000    -6.461053   -5.080042
------------------------------------------------------------------------------

. listcoef articles female, help

logit (N=2945): Factor Change in Odds 

  Odds of: Tenure vs NoTenure

----------------------------------------------------------------------
      tenure |      b         z     P>|z|    e^b    e^bStdX      SDofX
-------------+--------------------------------------------------------
    articles |   0.05091    6.562   0.000   1.0522   1.4097     6.7449
      female |  -0.37354   -2.941   0.003   0.6883   0.8341     0.4856
----------------------------------------------------------------------
       b = raw coefficient
       z = z-score for test of b=0
   P>|z| = p-value for z-test
     e^b = exp(b) = factor change in odds for unit increase in X
 e^bStdX = exp(b*SD of X) = change in odds for SD increase in X
   SDofX = standard deviation of X

. 
. // #3
. //  preditions with predict using pseudo-observations
. 
. set obs 2946
obs was 2945, now 2946

. replace female   =  1    if _n==2946
(1 real change made)

. replace articles =  0    if _n==2946
(1 real change made)

. replace year     =  7    if _n==2946
(1 real change made)

. replace yearsq   = 49    if _n==2946 // year squared
(1 real change made)

. replace select   =  4.97 if _n==2946 // mean level
(1 real change made)

. replace presthi  =  0.05 if _n==2946 // mean level
presthi was byte now float
(1 real change made)

. 
. predict prob in 2946
(option p assumed; Pr(tenure))
(2945 missing values generated)

. list prob female articles year yearsq select presthi in 2946, clean

            prob   female   articles   year   yearsq   select   presthi  
2946.   .1559942   Female          0      7       49     4.97       .05  

. drop in 2946
(1 observation deleted)

. 
. /*  Or you can use _N to determine the observation to be added.
> local newn = _N + 1
> set obs `newn'
> replace female   =  1    if _n==`newn'
> replace articles =  0    if _n==`newn'
> replace year     =  7    if _n==`newn'
> replace yearsq   = 49    if _n==`newn' // year squared
> replace select   =  4.97 if _n==`newn' // mean level
> replace presthi  =  0.05 if _n==`newn' // mean level
> predict prob in `newn'
> list prob female year yearsq select articles presthi in `newn', clean
> drop in `newn'
> */
. 
. // #4
. //  preditions with prvalue
. 
. prvalue, x(female=1 articles=0 year=7 yearsq=49) rest(mean)

logit: Predictions for tenure

Confidence intervals by delta method

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.1565   [ 0.1191,    0.1939]
  Pr(y=NoTenure|x):   0.8435   [ 0.8061,    0.8809]

       female       year     yearsq     select   articles    presthi
x=          1          7         49  4.9657725          0  .04516129

. 
. // #5
. //  multiple prvalues
. 
. prvalue, x(articles= 0 female=1 year=7 yearsq=49) brief

logit: Predictions for tenure

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.1565   [ 0.1191,    0.1939]
  Pr(y=NoTenure|x):   0.8435   [ 0.8061,    0.8809]

. prvalue, x(articles= 5 female=1 year=7 yearsq=49) brief

logit: Predictions for tenure

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.1931   [ 0.1552,    0.2311]
  Pr(y=NoTenure|x):   0.8069   [ 0.7689,    0.8448]

. prvalue, x(articles=10 female=1 year=7 yearsq=49) brief

logit: Predictions for tenure

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.2359   [ 0.1956,    0.2763]
  Pr(y=NoTenure|x):   0.7641   [ 0.7237,    0.8044]

. prvalue, x(articles=15 female=1 year=7 yearsq=49) brief

logit: Predictions for tenure

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.2848   [ 0.2382,    0.3315]
  Pr(y=NoTenure|x):   0.7152   [ 0.6685,    0.7618]

. prvalue, x(articles=20 female=1 year=7 yearsq=49) brief

logit: Predictions for tenure

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.3394   [ 0.2817,    0.3971]
  Pr(y=NoTenure|x):   0.6606   [ 0.6029,    0.7183]

. 
. // #6
. //  returns from prvalue
. 
. prvalue, x(articles= 0 female=1 year=7 yearsq=49) brief

logit: Predictions for tenure

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.1565   [ 0.1191,    0.1939]
  Pr(y=NoTenure|x):   0.8435   [ 0.8061,    0.8809]

. return list

scalars:
             r(p1_lo) =  .1191238284620015
             r(p1_hi) =  .1939323722807201
             r(p0_lo) =  .8060676128181188
             r(p0_hi) =  .8808761566368373
                r(p1) =  .1565281003713608
                r(p0) =  .843471884727478
             r(xb_hi) =  -1.400983333587647
             r(xb_lo) =  -1.967598676681519
                r(xb) =  -1.684291005134583

macros:
             r(level) : "95"

matrices:
                 r(x) :  1 x 6

. 
. // #7
. //  automating multiple prvalue's use forvalues
. 
. gen plotx = .
(2945 missing values generated)

.   label var plotx "Number of articles"

. gen plotp1 = .
(2945 missing values generated)

.   label var plotp1 "Pr(tenure for women in year 7)"

. local i = 0

. forvalues artval = 0(5)40 {
  2.     local ++i
  3.     prvalue, x(female=1 year=7 yearsq=49 articles=`artval')
  4.     replace plotx = `artval' if _n==`i'
  5.     replace plotp1 = r(p1) if _n==`i'
  6. }

logit: Predictions for tenure

Confidence intervals by delta method

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.1565   [ 0.1191,    0.1939]
  Pr(y=NoTenure|x):   0.8435   [ 0.8061,    0.8809]

       female       year     yearsq     select   articles    presthi
x=          1          7         49  4.9657725          0  .04516129
(1 real change made)
(1 real change made)

logit: Predictions for tenure

Confidence intervals by delta method

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.1931   [ 0.1552,    0.2311]
  Pr(y=NoTenure|x):   0.8069   [ 0.7689,    0.8448]

       female       year     yearsq     select   articles    presthi
x=          1          7         49  4.9657725          5  .04516129
(1 real change made)
(1 real change made)

logit: Predictions for tenure

Confidence intervals by delta method

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.2359   [ 0.1956,    0.2763]
  Pr(y=NoTenure|x):   0.7641   [ 0.7237,    0.8044]

       female       year     yearsq     select   articles    presthi
x=          1          7         49  4.9657725         10  .04516129
(1 real change made)
(1 real change made)

logit: Predictions for tenure

Confidence intervals by delta method

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.2848   [ 0.2382,    0.3315]
  Pr(y=NoTenure|x):   0.7152   [ 0.6685,    0.7618]

       female       year     yearsq     select   articles    presthi
x=          1          7         49  4.9657725         15  .04516129
(1 real change made)
(1 real change made)

logit: Predictions for tenure

Confidence intervals by delta method

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.3394   [ 0.2817,    0.3971]
  Pr(y=NoTenure|x):   0.6606   [ 0.6029,    0.7183]

       female       year     yearsq     select   articles    presthi
x=          1          7         49  4.9657725         20  .04516129
(1 real change made)
(1 real change made)

logit: Predictions for tenure

Confidence intervals by delta method

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.3985   [ 0.3260,    0.4711]
  Pr(y=NoTenure|x):   0.6015   [ 0.5289,    0.6740]

       female       year     yearsq     select   articles    presthi
x=          1          7         49  4.9657725         25  .04516129
(1 real change made)
(1 real change made)

logit: Predictions for tenure

Confidence intervals by delta method

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.4608   [ 0.3718,    0.5499]
  Pr(y=NoTenure|x):   0.5392   [ 0.4501,    0.6282]

       female       year     yearsq     select   articles    presthi
x=          1          7         49  4.9657725         30  .04516129
(1 real change made)
(1 real change made)

logit: Predictions for tenure

Confidence intervals by delta method

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.5244   [ 0.4194,    0.6293]
  Pr(y=NoTenure|x):   0.4756   [ 0.3707,    0.5806]

       female       year     yearsq     select   articles    presthi
x=          1          7         49  4.9657725         35  .04516129
(1 real change made)
(1 real change made)

logit: Predictions for tenure

Confidence intervals by delta method

                                95% Conf. Interval
  Pr(y=Tenure|x):     0.5871   [ 0.4691,    0.7052]
  Pr(y=NoTenure|x):   0.4129   [ 0.2948,    0.5309]

       female       year     yearsq     select   articles    presthi
x=          1          7         49  4.9657725         40  .04516129
(1 real change made)
(1 real change made)

. graph twoway connected plotp1 plotx, ///
>      xlabel(0(5)40) ylabel(0(.1).8) ///
>      ytitle("Pr(tenure for women in year 7)")

. graph export sug_groups_07_prvalue.emf, replace
(file e:\analysis\stataboston\work\sug_groups_07_prvalue.emf written in Enhanced Metafile forma
> t)

. 
. * add marker
. gen plotp2 = plotp1 if _n==1
(2944 missing values generated)

. 
. twoway (connected plotp1 plotx) ///
>        (connected plotp2 plotx, msym(Sh) msize(large) clcol(red)) ///
>      , xlabel(0(5)40) ylabel(0(.1).6) legend(off) ///
>      ytitle("Pr(tenure for women in year 7)")

. graph export sug_groups_07_prvalue_eg.emf, replace
(file e:\analysis\stataboston\work\sug_groups_07_prvalue_eg.emf written in Enhanced Metafile fo
> rmat)

. 
. // #8
. //  plot with prgen
. 
. prgen articles, from(0) to(40) gap(5) generate(m0) x(female=1 year=7 yearsq=49)

logit: Predicted values as articles varies from 0 to 40.

       female       year     yearsq     select   articles    presthi
x=          1          7         49  4.9657725  7.2091681  .04516129

. label var m0p1 "Pr(tenure for women in year 7)"

. label var m0x  "Number of articles"

. 
. graph twoway connected m0p1 m0x, ///
>      xlabel(0(5)40) ylabel(0(.1).6)

. graph export sug_groups_08_prgen.emf, replace
(file e:\analysis\stataboston\work\sug_groups_08_prgen.emf written in Enhanced Metafile format)

. drop m0*

. 
. // #9
. //  plot with logit using ci's
. 
. prgen articles, from(0) to(40) gap(5) generate(m0) ///
>     x(female=1 year=7 yearsq=49) ci

logit: Predicted values as articles varies from 0 to 40.

       female       year     yearsq     select   articles    presthi
x=          1          7         49  4.9657725  7.2091681  .04516129

. label var m0p1 "Pr(tenure for women in year 7)"

. label var m0x  "Number of articles"

. label var m0p1lb "95% lower bound"

. label var m0p1ub "95% upper bound"

. 
. * using shading to show confidence interval
. graph twoway ///
>     (rarea m0p1lb m0p1ub m0x, color(gs14)) ///
>     (connected m0p1 m0x, msymbol(i)), ///
>      subtitle("Probability of tenure with 95% confidence interval") ///
>      yscale(range(0 .6)) ytitle("Pr(tenure for women in year 7)") ///
>      xlabel(0(5)40) legend(off)

. 
. graph export sug_groups_09_prgenci.emf, replace
(file e:\analysis\stataboston\work\sug_groups_09_prgenci.emf written in Enhanced Metafile forma
> t)

. 
. // #10
. //  change in predictions
. 
. prchange female, x(year=7 yearsq=47)

logit: Changes in Probabilities for tenure

        min->max      0->1     -+1/2    -+sd/2  MargEfct
female   -0.0726   -0.0726   -0.0741   -0.0360   -0.0742

         NoTenure    Tenure
Pr(y|x)    0.7268    0.2732

          female      year    yearsq    select  articles   presthi
    x=   .380645         7        47   4.96577   7.20917   .045161
sd(x)=   .485628   3.09029   44.1814   1.43395   6.74494   .207693

. 
. quietly prvalue, x(female=0 year=7 yearsq=47) save

.         prvalue, x(female=1 year=7 yearsq=47) dif

logit: Change in Predictions for tenure

Confidence intervals by delta method

                     Current     Saved    Change   95% CI for Change
  Pr(y=Tenure|x):     0.2298    0.3024   -0.0726  [-0.1201,  -0.0251]
  Pr(y=NoTenure|x):   0.7702    0.6976    0.0726  [ 0.0251,   0.1201]

             female       year     yearsq     select   articles    presthi
Current=          1          7         47  4.9657725  7.2091681  .04516129
  Saved=          0          7         47  4.9657725  7.2091681  .04516129
   Diff=          1          0          0          0          0          0

. 
. //
. //  single predictor of tenure
. //
. 
. // #11
. //  variables in articles only model
. 
. spex tenure01, clear

. use "http://www.indiana.edu/~jslsoc/stata/spex_data/tenure01.dta", clear

. sort male

. by male: sum tenure female f_articles male m_articles

-----------------------------------------------------------------------------------------------
-> male = Female

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
      tenure |      1121    .1079393    .3104423          0          1
      female |      1121           1           0          1          1
  f_articles |      1121    7.555754    7.612886          0         73
        male |      1121           0           0          0          0
  m_articles |      1121           0           0          0          0

-----------------------------------------------------------------------------------------------
-> male = Male

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
      tenure |      1824    .1326754    .3393167          0          1
      female |      1824           0           0          0          0
  f_articles |      1824           0           0          0          0
        male |      1824           1           0          1          1
  m_articles |      1824    6.996162    6.143599          0         49


. 
. by male: vardesc tenure year yearsq select articles presthi

-----------------------------------------------------------------------------------------------
-> male = Female

Variable         Mean   StdDev  Minimum  Maximum  Label                  
tenure           0.11     0.31     0.00     1.00  Is tenured?            
year             4.53     3.27     1.00    22.00  Years in rank.         
yearsq          31.22    49.11     1.00   484.00  Years in rank squared. 
select           5.01     1.48     1.00     7.00  Selectivity of bachelor's
articles         7.56     7.61     0.00    73.00  Total number of articles.
presthi          0.05     0.23     0.00     1.00  Prestige is 4 or higher?

N = 1121

-----------------------------------------------------------------------------------------------
-> male = Male

Variable         Mean   StdDev  Minimum  Maximum  Label                  
tenure           0.13     0.34     0.00     1.00  Is tenured?            
year             4.21     2.97     1.00    20.00  Years in rank.         
yearsq          26.49    40.77     1.00   400.00  Years in rank squared. 
select           4.94     1.41     1.00     7.00  Selectivity of bachelor's
articles         7.00     6.14     0.00    49.00  Total number of articles.
presthi          0.04     0.19     0.00     1.00  Prestige is 4 or higher?

N = 1824

. 
. // #12
. //  estimate logit model by group
. 
. logit tenure female f_articles male m_articles, nolog nocon

Logistic regression                               Number of obs   =       2945
                                                  LR chi2(4)      =          .
Log likelihood = -1038.1979                       Prob > chi2     =          .

------------------------------------------------------------------------------
      tenure |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      female |  -2.473265   .1351554   -18.30   0.000    -2.738165   -2.208365
  f_articles |   .0421485   .0098962     4.26   0.000     .0227524    .0615446
        male |  -2.693147   .1170909   -23.00   0.000    -2.922641   -2.463653
  m_articles |   .0980976   .0098808     9.93   0.000     .0787317    .1174635
------------------------------------------------------------------------------

. 
. // #13
. //  incorrect chow test
. 
. listcoef f_articles m_articles

logit (N=2945): Factor Change in Odds 

  Odds of: Tenure vs NoTenure

----------------------------------------------------------------------
      tenure |      b         z     P>|z|    e^b    e^bStdX      SDofX
-------------+--------------------------------------------------------
  f_articles |   0.04215    4.259   0.000   1.0430   1.2855     5.9592
  m_articles |   0.09810    9.928   0.000   1.1031   1.7854     5.9089
----------------------------------------------------------------------

. test f_articles = m_articles

 ( 1)  f_articles - m_articles = 0

           chi2(  1) =   16.01
         Prob > chi2 =    0.0001

. 
. // #14
. //  compute predictions at different #s of articles
. 
. * predictions with 5 articles
. quietly prvalue, x(fem=1 f_art=5 male=0 m_art=0) save

.         prvalue, x(fem=0 f_art=0 male=1 m_art=5) dif

logit: Change in Predictions for tenure

Confidence intervals by delta method

                     Current     Saved    Change   95% CI for Change
  Pr(y=Tenure|x):     0.0995    0.0943    0.0052  [-0.0179,   0.0284]
  Pr(y=NoTenure|x):   0.9005    0.9057   -0.0052  [-0.0284,   0.0179]

              female  f_articles        male  m_articles
Current=           0           0           1           5
  Saved=           1           5           0           0
   Diff=          -1          -5           1           5

. 
. matrix drop _all

. foreach art of numlist 0(2)50 {
  2.     quietly prvalue, x(fem=1 f_art=`art' male=0 m_art=0)
  3.     matrix y_fem = nullmat(y_fem) \ pepred[2,2]
  4.     quietly prvalue, x(fem=0 f_art=0 male=1 m_art=`art')
  5.     matrix y_mal = nullmat(y_mal) \ pepred[2,2]
  6.     matrix x_art = nullmat(x_art) \ `art'
  7. }

. svmat x_art

. label var x_art1 "Number of Articles"

. svmat y_fem

. label var y_fem1 "Women" // Pr(for women)

. svmat y_mal

. label var y_mal1 "Men"   // Pr(for men)

. 
. // #15
. //  plot predictions at different #s of articles
. 
. twoway (connected y_fem x_art, msym(i) clcol(red)) ///
>        (connected y_mal x_art, msym(i) clcol(blue)) ///
>       , ytitle(Pr(tenure)) xlabel(0(10)50) ///
>         ylabel(0(.2)1.) yline(0 1) legend(pos(11) ring(0) cols(1))

. graph export sug_groups_15_artprob.emf, replace
(file e:\analysis\stataboston\work\sug_groups_15_artprob.emf written in Enhanced Metafile forma
> t)

. 
. * cleanup
. matrix drop _all

. capture drop x_art1 y_fem1 y_mal1

. 
. // #16
. //  compute discrete change and ci (sb_groups_m1ci.log)
. 
. foreach art of numlist 0(2)50 {
  2.     quietly prvalue, save /// for women
>        x(fem=1 f_art=`art' male=0 m_art=0)
  3.     quietly prvalue, diff /// for men
>        x(fem=0 f_art=0 male=1 m_art=`art')
  4.     matrix y_mal = nullmat(y_mal) \ pepred[2,2]
  5.     matrix y_fem = nullmat(y_fem) \ pepred[4,2]
  6.     matrix y_dc  = nullmat(y_dc)  \ pepred[6,2]
  7.     matrix y_ub  = nullmat(y_ub)  \ peupper[6,2]
  8.     matrix y_lb  = nullmat(y_lb)  \ pelower[6,2]
  9.     matrix x_art = nullmat(x_art) \ `art'
 10. }

. 
. // #17
. //  plot discrete change and ci (sb_groups_m1ciplot.log)
. 
. foreach v in x_art y_dc y_ub y_lb y_fem y_mal {
  2.     svmat `v'
  3. }

. label var x_art "Number of Articles"

. label var y_fem "Women" // Pr(for women)

. label var y_mal "Men"   // Pr(for men)

. label var y_dc  "Difference" // Pr(for men) - Pr(for women)

. label var y_ub  "95% confidence interval"

. label var y_lb  "95% confidence interval"

. 
. twoway ///
>     (connected y_dc x_art, msym(i) clcol(green)) ///
>     (connected y_ub x_art, msym(i) clcol(brown) clpat(dash)) ///
>     (connected y_lb x_art, msym(i) clcol(brown) clpat(dash)) ///
>     , legend(pos(11) ring(0) cols(1) order(1 2)) ///
>     ytitle("Pr(men) - Pr(women)") ylabel(-.1(.1).8) yline(0) ///
>     xlabel(0(10)50)

. 
. graph export sug_groups_17_artdc.emf, replace
(file e:\analysis\stataboston\work\sug_groups_17_artdc.emf written in Enhanced Metafile format)

. 
. //
. //  M2 articles and hiprestige as a predictor
. //
. 
. // #18
. //  logit estimated (sb_groups_m2logit.log)
. 
. matrix drop _all

. spex tenure01, clear

. use "http://www.indiana.edu/~jslsoc/stata/spex_data/tenure01.dta", clear

. 
. logit tenure female f_art f_presthi ///
>                male m_art m_presthi, nolog nocon

Logistic regression                               Number of obs   =       2945
                                                  LR chi2(6)      =          .
Log likelihood = -1032.3002                       Prob > chi2     =          .

------------------------------------------------------------------------------
      tenure |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      female |  -2.543769   .1421109   -17.90   0.000    -2.822302   -2.265237
  f_articles |   .0572428   .0114595     5.00   0.000     .0347826     .079703
   f_presthi |  -1.634833   .6719782    -2.43   0.015    -2.951886   -.3177794
        male |  -2.684516   .1173755   -22.87   0.000    -2.914568   -2.454464
  m_articles |   .1001105   .0099969    10.01   0.000     .0805168    .1197041
   m_presthi |  -.7295205   .4259048    -1.71   0.087    -1.564279    .1052376
------------------------------------------------------------------------------

. 
. // #19
. //  chow tests
.     test f_art = m_art

 ( 1)  f_articles - m_articles = 0

           chi2(  1) =    7.95
         Prob > chi2 =    0.0048

.     test f_presthi  = m_presthi

 ( 1)  f_presthi - m_presthi = 0

           chi2(  1) =    1.29
         Prob > chi2 =    0.2552

. 
. // #20
. //  compute predictions at both levels of presthi (sb_groups_m2pred.log)
. 
. foreach art of numlist 0(2)50 {
  2.     * lower prestige jobs
.     quietly prvalue, save /// for women
>         x(fem=1 f_art=`art' male=0 m_art=0     f_presthi=0 m_presthi=0)
  3.     quietly prvalue, diff /// for men
>         x(fem=0 f_art=0     male=1 m_art=`art' f_presthi=0 m_presthi=0)
  4.     matrix xlo_art = nullmat(xlo_art) \ `art'        // articles
  5.     matrix ylo_mal = nullmat(ylo_mal) \ pepred[2,2]  // pr men
  6.     matrix ylo_fem = nullmat(ylo_fem) \ pepred[4,2]  // pr women
  7.     matrix ylo_dc = nullmat(ylo_dc)   \ pepred[6,2]  // difference
  8.     matrix ylo_ub = nullmat(ylo_ub)   \ peupper[6,2] // upper limit
  9.     matrix ylo_lb = nullmat(ylo_lb)   \ pelower[6,2] // lower limit
 10. 
.     * high prestige jobs
.     quietly prvalue, save /// for women
>         x(fem=1 f_art=`art' male=0 m_art=0     f_presthi=1 m_presthi=0)
 11.     quietly prvalue, diff /// for men
>         x(fem=0 f_art=0     male=1 m_art=`art' f_presthi=0 m_presthi=1)
 12.     matrix xhi_art  = nullmat(xhi_art) \ `art'
 13.     matrix yhi_mal  = nullmat(yhi_mal) \ pepred[2,2]
 14.     matrix yhi_fem  = nullmat(yhi_fem) \ pepred[4,2]
 15.     matrix yhi_dc   = nullmat(yhi_dc)  \ pepred[6,2]
 16.     matrix yhi_ub = nullmat(yhi_ub)    \ peupper[6,2]
 17.     matrix yhi_lb = nullmat(yhi_lb)    \ pelower[6,2]
 18. }

. 
. foreach v in xlo_art ylo_fem ylo_mal ylo_dc ylo_ub ylo_lb ///
>              xhi_art yhi_fem yhi_mal yhi_dc yhi_ub yhi_lb {
  2.     svmat `v'
  3. }

. label var xlo_art1 "Number of Articles"

. label var ylo_fem1 "Women - not distinguished"

. label var ylo_mal1 "Men - not distinguished"

. label var yhi_fem1 "Women - distinguished"

. label var yhi_mal1 "Men - distinguished"

. label var ylo_dc1  "Male-Female - not distinguished"

. label var ylo_ub1  "95% confidence interval"

. label var ylo_lb1  "95% confidence interval"

. label var yhi_dc1  "Male-Female - distinguished"

. label var yhi_lb1  "95% confidence interval"

. label var yhi_ub1  "95% confidence interval"

. 
. // #21
. //  four probability curves (sb_groups_m2plotprob.log)
. 
. twoway ///
>     (connected yhi_fem xhi_art, msym(i) clcol(red) clpat(solid)) ///
>     (connected ylo_fem xlo_art, msym(i) clcol(red) clpat(shortdash_dot)) ///
>     (connected yhi_mal xhi_art, msym(i) clcol(blue) clpat(solid)) ///
>     (connected ylo_mal xlo_art, msym(i) clcol(blue) clpat(shortdash_dot)) ///
>     , legend(pos(11) order(2 1 4 3) ring(0) cols(1) region(ls(none)))  ///
>       ylabel(0(.2)1.) yline(0 1) ytitle(Pr(tenure)) xlabel(0(10)50)

. graph export sug_groups_21_prprsthi.emf, replace
(file e:\analysis\stataboston\work\sug_groups_21_prprsthi.emf written in Enhanced Metafile form
> at)

. 
. // #22
. //  two DC curves (sb_groups_m2dcplot.log)
. 
. twoway ///
>     (connected ylo_dc xlo_art, msym(i) clcol(green))             ///
>     (connected yhi_dc xhi_art, msym(i) clcol(orange))            ///
>     , legend(pos(11) ring(0) cols(1) order(1 2)) xlabel(0(10)50) ///
>       ytitle("Pr(men) - Pr(women)") ylabel(-.1(.2).9) yline(0)

. graph export sug_groups_22_dcprst.emf, replace
(file e:\analysis\stataboston\work\sug_groups_22_dcprst.emf written in Enhanced Metafile format
> )

. 
. // #23
. //  plot discrete change with ci's (sb_groups_m2dcplotsig.log)
. 
. * case as missing if not significant
. gen ylo_sigdc = ylo_dc if ylo_lb>=0 & ylo_lb!=.
(2924 missing values generated)

. gen yhi_sigdc = yhi_dc if yhi_lb>=0 & yhi_lb!=.
(2928 missing values generated)

. label var ylo_sigdc "Not distinguished"

. label var ylo_dc  "if not significant"

. label var yhi_sigdc "Distinguished"

. label var yhi_dc  "if not significant"

. 
. twoway ///
>     (connected ylo_sigdc xlo_art, clpat(solid) msym(i) clcol(green) ) ///
>     (connected yhi_sigdc xhi_art, clpat(solid) msym(i) clcol(orange)) ///
>     (connected ylo_dc    xlo_art, clpat(dash)  msym(i) clcol(green) ) ///
>     (connected yhi_dc    xhi_art, clpat(dash)  msym(i) clcol(orange)) ///
>     , legend(pos(11) order(2 4 1 3) ring(0) cols(1) region(ls(none))) ///
>       ytitl("Pr(men) - Pr(women)") xlab(0(10)50) ylab(-.1(.2).9) ylin(0)

. graph export sug_groups_23_dcsigprsthi.emf, replace
(file e:\analysis\stataboston\work\sug_groups_23_dcsigprsthi.emf written in Enhanced Metafile f
> ormat)

. 
. //
. //  full model
. //
. 
. // #25
. //  estimate full model (sb_groups_m3logit.log)
. 
. matrix drop _all

. spex tenure01, clear

. use "http://www.indiana.edu/~jslsoc/stata/spex_data/tenure01.dta", clear

. 
. logit tenure male m_year m_yearsq m_select m_articles m_prestige ///
>              fem  f_year f_yearsq f_select f_articles f_prestige, nolog nocon

Logistic regression                               Number of obs   =       2945
                                                  LR chi2(12)     =          .
Log likelihood = -918.07144                       Prob > chi2     =          .

------------------------------------------------------------------------------
      tenure |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        male |   -5.82375   .5041622   -11.55   0.000    -6.811889    -4.83561
      m_year |   1.071883   .1180005     9.08   0.000     .8406058    1.303159
    m_yearsq |  -.0654023   .0087056    -7.51   0.000     -.082465   -.0483397
    m_select |   .2107227   .0571501     3.69   0.000     .0987106    .3227349
  m_articles |   .0735537   .0107594     6.84   0.000     .0524656    .0946417
  m_prestige |  -.3770013    .103439    -3.64   0.000     -.579738   -.1742646
      female |  -4.207207    .630249    -6.68   0.000    -5.442473   -2.971942
      f_year |   .7685059   .1255128     6.12   0.000     .5225053    1.014507
    f_yearsq |  -.0417568   .0084699    -4.93   0.000    -.0583575   -.0251561
    f_select |   .0344378   .0683684     0.50   0.614    -.0995617    .1684373
  f_articles |   .0356986   .0119722     2.98   0.003     .0122335    .0591638
  f_prestige |  -.3481816    .152196    -2.29   0.022    -.6464803   -.0498829
------------------------------------------------------------------------------

. 
. // #26
. //  compute means for rhs variable (sb_groups_m3means.log)
. 
. foreach v in year yearsq select art prestige {
  2.     quietly sum `v'
  3.     local mn_`v' = r(mean)
  4. }

. local mn_yr = 7 // year for predictions

. local mn_yrsq = `mn_yr' * `mn_yr' // year squared

. local f_at_mn "f_year=`mn_yr' f_yearsq=`mn_yrsq' f_select=`mn_select'"

. local m_at_mn "m_year=`mn_yr' m_yearsq=`mn_yrsq' m_select=`mn_select'"

. local m_at_0  "mal=0 m_art=0 m_year=0 m_yearsq=0 m_select=0 m_prestige=0"

. local f_at_0  "fem=0 f_art=0 f_year=0 f_yearsq=0 f_select=0 f_prestige=0"

. 
. 
. // #27
. //  compute predictions at year 7
. 
. foreach p in 1 2 3 4 5 { // prestige level
  2. 
.     di "prestige at `p'"
  3. 
.     foreach art of numlist 0(2)50 { // loop through articles
  4. 
.         quietly prvalue, save ///
>           x(fem=1 f_art=`art' f_prestige=`p' `f_at_mn' `m_at_0')
  5.         quietly prvalue, diff ///
>           x(mal=1 m_art=`art' m_prestige=`p' `m_at_mn' `f_at_0')
  6. 
.         matrix x`p'_art = nullmat(x`p'_art) \ `art'
  7.         matrix y`p'_mal = nullmat(y`p'_mal) \ pepred[2,2]
  8.         matrix y`p'_fem = nullmat(y`p'_fem) \ pepred[4,2]
  9.         matrix y`p'_dc  = nullmat(y`p'_dc)  \ pepred[6,2]
 10.         matrix y`p'_ub  = nullmat(y`p'_ub)  \ peupper[6,2]
 11.         matrix y`p'_lb  = nullmat(y`p'_lb)  \ pelower[6,2]
 12.     }
 13. 
.     foreach v in x`p'_art y`p'_dc y`p'_ub y`p'_lb y`p'_fem y`p'_mal {
 14.         svmat `v'
 15.     }
 16.     label var x`p'_art1 "Number of Articles"
 17.     label var y`p'_mal1 "Men"
 18.     label var y`p'_fem1 "Women"
 19.     label var y`p'_dc1  "Male-Female difference"
 20.     label var y`p'_ub1  "95% confidence interval"
 21.     label var y`p'_lb1  "95% confidence interval"
 22. 
. } // end of prediction loop
prestige at 1
prestige at 2
prestige at 3
prestige at 4
prestige at 5

. 
. // #28
. //  probability plots by level of prestige
. 
. foreach p in 1 2 3 4 5 { // prestige level
  2. 
.     twoway ///
>       (connected y`p'_fem x`p'_art, msym(i) clcol(red)) ///
>       (connected y`p'_mal x`p'_art, msym(i) clcol(blue)) ///
>      , subtitle("Plotted at prestige = `p'",pos(11)) ///
>        legend(pos(11) order(2 1) ring(0) cols(1) region(ls(none))) ///
>        ytitle(Pr(tenure)) xlabel(0(10)50) ///
>        ylabel(0(.2)1.) yline(0 1)
  3.     graph export sug_groups_28_probprst`p'.emf, replace
  4. 
.     * discrete change in probability
.     twoway ///
>       (connected y`p'_dc x`p'_art, msym(i) clcol(orange)) ///
>       (connected y`p'_ub x`p'_art, msym(i) clcol(brown) clpat(dash)) ///
>       (connected y`p'_lb x`p'_art, msym(i) clcol(brown) clpat(dash)) ///
>      , subtitle("Plotted at prestige = `p'",pos(11)) ///
>        legend(pos(11) order(2 1) ring(0) cols(1) region(ls(none))) ///
>        ytitle("Pr(men) - Pr(women)") xlabel(0(10)50) ///
>        ylabel(-.1(.2).7) yline(0)
  5.     graph export sug_groups_28_dcprst`p'.emf, replace
  6. 
. } // loop over prestige
(file e:\analysis\stataboston\work\sug_groups_28_probprst1.emf written in Enhanced Metafile for
> mat)
(file e:\analysis\stataboston\work\sug_groups_28_dcprst1.emf written in Enhanced Metafile forma
> t)
(file e:\analysis\stataboston\work\sug_groups_28_probprst2.emf written in Enhanced Metafile for
> mat)
(file e:\analysis\stataboston\work\sug_groups_28_dcprst2.emf written in Enhanced Metafile forma
> t)
(file e:\analysis\stataboston\work\sug_groups_28_probprst3.emf written in Enhanced Metafile for
> mat)
(file e:\analysis\stataboston\work\sug_groups_28_dcprst3.emf written in Enhanced Metafile forma
> t)
(file e:\analysis\stataboston\work\sug_groups_28_probprst4.emf written in Enhanced Metafile for
> mat)
(file e:\analysis\stataboston\work\sug_groups_28_dcprst4.emf written in Enhanced Metafile forma
> t)
(file e:\analysis\stataboston\work\sug_groups_28_probprst5.emf written in Enhanced Metafile for
> mat)
(file e:\analysis\stataboston\work\sug_groups_28_dcprst5.emf written in Enhanced Metafile forma
> t)

. 
. // #29
. //  plot of multiple prestige levels
. 
. * case as missing if not significant
. foreach p in 1 2 3 4 5 {
  2.      gen y`p'_sigdc = y`p'_dc if y`p'_lb>=0 & y`p'_lb!=.
  3. }
(2927 missing values generated)
(2922 missing values generated)
(2923 missing values generated)
(2926 missing values generated)
(2930 missing values generated)

. 
. label var y1_sigdc "Weak (prestige=1)"

. label var y1_dc  "  (not significant)"

. label var y2_sigdc "Adequate (prestige=2)"

. label var y3_sigdc "Good (prestige=3)"

. label var y4_sigdc "Strong (prestige=4)"

. label var y5_sigdc "Distinguished (prestige=5)"

. label var y5_dc  "  (not significant)"

. 
. twoway ///
>   (connected y1_sigdc x1_art, clpat(solid) msym(i) clcol(red))    ///
>   (connected y2_sigdc x2_art, clpat(solid) msym(i) clcol(orange)) ///
>   (connected y3_sigdc x3_art, clpat(solid) msym(i) clcol(green))  ///
>   (connected y4_sigdc x4_art, clpat(solid) msym(i) clcol(blue))   ///
>   (connected y5_sigdc x5_art, clpat(solid) msym(i) clcol(purple)) ///
>   (connected y1_dc    x1_art, clpat(dash)  msym(i) clcol(red))    ///
>   (connected y2_dc    x2_art, clpat(dash)  msym(i) clcol(orange)) ///
>   (connected y3_dc    x3_art, clpat(dash)  msym(i) clcol(green))  ///
>   (connected y4_dc    x4_art, clpat(dash)  msym(i) clcol(blue))   ///
>   (connected y5_dc    x5_art, clpat(dash)  msym(i) clcol(purple)) ///
>  , legend(pos(11) order(1 2 3 4 5) ring(0) cols(1) region(ls(none))) ///
>    ytitle("Pr(men) - Pr(women)") xlab(0(10)50) ylab(.0(.1).5) ylin(0)

. graph export sug_groups_29_dcprst.emf, replace
(file e:\analysis\stataboston\work\sug_groups_29_dcprst.emf written in Enhanced Metafile format
> )

. 
. // #30
. //  compute predictions at year 7 for various levels of publications
. 
. local a = 0

. foreach art in 0 10 20 30 40 50 { // articles
  2. 
.     local ++a // to number variables that are created
  3.     di "articles = `art'"
  4. 
.     foreach p of numlist 1(.2)5 { // loop through prestige
  5. 
.         quietly prvalue, save ///
>           x(fem=1 f_art=`art' f_prestige=`p' `f_at_mn' `m_at_0')
  6.         quietly prvalue, diff ///
>           x(mal=1 m_art=`art' m_prestige=`p' `m_at_mn' `f_at_0')
  7. 
.         matrix x`a'a_prst = nullmat(x`a'a_prst) \ `p'
  8.         matrix y`a'a_mal  = nullmat(y`a'a_mal)  \ pepred[2,2]
  9.         matrix y`a'a_fem  = nullmat(y`a'a_fem)  \ pepred[4,2]
 10.         matrix y`a'a_dc   = nullmat(y`a'a_dc)   \ pepred[6,2]
 11.         matrix y`a'a_ub   = nullmat(y`a'a_ub)   \ peupper[6,2]
 12.         matrix y`a'a_lb   = nullmat(y`a'a_lb)   \ pelower[6,2]
 13. 
.     }  // prestige level
 14. 
. } // end of articles loop
articles = 0
articles = 10
articles = 20
articles = 30
articles = 40
articles = 50

. 
. // #31
. //  plot of multiple article levels
. 
. * create variables to plot
. foreach a in 1 2 3 4 5 6 {
  2.     foreach v in x`a'a_prst y`a'a_dc y`a'a_ub y`a'a_lb y`a'a_fem y`a'a_mal {
  3.         svmat `v'
  4.     }
  5.     label var x`a'a_prst "Job Prestige"
  6.     label var y`a'a_mal  "Men"
  7.     label var y`a'a_fem  "Women"
  8.     label var y`a'a_dc   "Male-Female difference"
  9.     label var y`a'a_ub   "95% confidence interval"
 10.     label var y`a'a_lb   "95% confidence interval"
 11. 
. }

. 
. * create new variable to indicate significance
. foreach a in 1 2 3 4 5 6 {
  2.      gen y`a'a_sigdc = y`a'a_dc if y`a'a_lb>=0 & y`a'a_lb!=.
  3. }
(2945 missing values generated)
(2933 missing values generated)
(2925 missing values generated)
(2924 missing values generated)
(2924 missing values generated)
(2925 missing values generated)

. 
. * creaet plot
. label var y1a_sigdc "no articles"

. label var y1a_dc    "  (not significant)"

. label var y2a_sigdc "10 articles"

. label var y3a_sigdc "20 articles"

. label var y4a_sigdc "30 articles"

. label var y5a_sigdc "40 articles"

. label var y6a_sigdc "50 articles"

. label var y6a_dc    "  (not significant)"

. */
. twoway ///
>   (connected y1a_sigdc x1a_prst, clpat(solid) msym(i) clcol(red))    ///
>   (connected y2a_sigdc x2a_prst, clpat(solid) msym(i) clcol(orange)) ///
>   (connected y3a_sigdc x3a_prst, clpat(solid) msym(i) clcol(brown))  ///
>   (connected y4a_sigdc x4a_prst, clpat(solid) msym(i) clcol(green))  ///
>   (connected y5a_sigdc x5a_prst, clpat(solid) msym(i) clcol(blue))   ///
>   (connected y6a_sigdc x6a_prst, clpat(solid) msym(i) clcol(purple)) ///
>   (connected y1a_dc    x1a_prst, clpat(dash)  msym(i) clcol(red))    ///
>   (connected y2a_dc    x2a_prst, clpat(dash)  msym(i) clcol(orange)) ///
>   (connected y3a_dc    x3a_prst, clpat(dash)  msym(i) clcol(brown))  ///
>   (connected y4a_dc    x4a_prst, clpat(dash)  msym(i) clcol(green))  ///
>   (connected y5a_dc    x5a_prst, clpat(dash)  msym(i) clcol(blue))   ///
>   (connected y6a_dc    x6a_prst, clpat(dash)  msym(i) clcol(purple)) ///
>  , legend(pos(11) order(1 2 3 4 5 6) ring(0) cols(2) region(ls(none))) ///
>    ytitle("Pr(men) - Pr(women)") xlab(1(1)5) ylab(.0(.1).5) ylin(0)

. 
. graph export sug_groups_31_dcart.emf, replace
(file e:\analysis\stataboston\work\sug_groups_31_dcart.emf written in Enhanced Metafile format)

. 
. /*
> // #0
> //  installing spost
> 
> net from http://www.indiana.edu/~jslsoc/stata/
> 
> //  or:
> 
> findit spost9
> */
. */
. 
. log close
       log:  e:\analysis\stataboston\work\sug_groups_tenure.log
  log type:  text
 closed on:  20 Jul 2006, 09:49:42
-----------------------------------------------------------------------------------------------