------------------------------------------------------------------------------------------------------
       log:  c:\Imbook\bwebpage\Section4\mma19p1comprisks.txt
  log type:  text
 opened on:  19 May 2005, 17:52:44

. 
. ********** OVERVIEW OF MMA18P1COMPRISKS.DO **********
. 
. * STATA Program 
. * copyright C 2005 by A. Colin Cameron and Pravin K. Trivedi 
. * used for "Microeconometrics: Methods and Applications" 
. * by A. Colin Cameron and Pravin K. Trivedi (2005)
. * Cambridge University Press 
. 
. * Chapter 19.5 pages 658-62
. * Competing Risks Example with censoring mechanism each of the three risks
. *   (1A) Table 19.2 p.659  Exponential
. *   (1B) Table 19.2 p.659  Exponential with IG frailty
. *   (2A) Table 19.3 p.659  Weibull
. *   (2B) Table 19.3 p.659  Weibull with IG frailty
. *   (2C) Table 19.3 p.660  Cox model
. *   (2D) Graph the resulting Cox baseline survival and cumulative hazards
. *        Figure 19.1: (combined_bsf.wmf) baseline survival functions
. *        Figure 19.2: (combined_cbh.wmf) baseline cumulative hazards
. 
. * To run this program you need data file
. *    ema1996.dta
. 
. * NOTE: The IG Heterogeneity estimation was unsuccessful for exponential
. *       but successful for Weibull
. 
. ********** SETUP **********
. 
. set more off

. version 8

. set scheme s1mono   /* Used for graphs */

. set matsize 80     /* Needed for this program */

.   
. ********** DATA DESCRIPTION **********
. 
. * The data is from 
. * B.P. McCall (1996), "Unemployment Insurance Rules, Joblessness, 
. *                      and Part-time Work," Econometrica, 64, 647-682.
. 
. * There are 3343 observations from the CPS Displaced Worker Surveys
. * of 1986, 1988, 1990 and 1992 on 33 variables including
. *    spell = length of spell in number of two-week intervals
. *  CENSOR1 = 1 if re-employed at full-time job
. *  CENSOR2 = 1 if re-employed at part-time job
. *  CENSOR3 = 1 if re-employed but left job: pt-ft status unknown
. *  CENSOR4 = 1 if still jobless
. 
. * See program mma17p4duration.do for further description of the data set
. 
. ********** READ DATA and CREATE ADDITIONAL VARIABLES **********
. 
. use ema1996.dta
(Sample for 1996 EMA paper: part-time= worked part-time last week)

. 
. gen RR = reprate

. gen DR = disrate

. gen UI = ui

. gen RRUI = RR*UI

. gen DRUI = DR*UI

. gen LOGWAGE = logwage

. sum

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       spell |      3343    6.247981    5.611271          1         28
     censor1 |      3343    .3209692    .4669188          0          1
     censor2 |      3343    .1014059    .3019106          0          1
     censor3 |      3343    .1717021    .3771777          0          1
     censor4 |      3343    .3754113    .4843014          0          1
-------------+--------------------------------------------------------
          ui |      3343    .5527969    .4972791          0          1
     reprate |      3343    .4544717    .1137918       .066      2.059
     logwage |      3343    5.692994    .5356591    2.70805   7.600402
      tenure |      3343    4.114867    5.862322          0         40
     disrate |      3343    .1094376    .0735274       .002       1.02
-------------+--------------------------------------------------------
       slack |      3343    .4884834    .4999421          0          1
     abolpos |      3343    .1456775    .3528354          0          1
     explose |      3343    .5025426    .5000683          0          1
     stateur |      3343      6.5516    1.803825        2.5         13
    houshead |      3343    .6120251    .4873617          0          1
-------------+--------------------------------------------------------
     married |      3343    .5860006    .4926221          0          1
      female |      3343    .3478911    .4763725          0          1
       child |      3343    .4501944    .4975876          0          1
      ychild |      3343    .1956327    .3967463          0          1
    nonwhite |      3343    .1390966    .3460991          0          1
-------------+--------------------------------------------------------
         age |      3343    35.44331     10.6402         20         61
     schlt12 |      3343    .2811846    .4496446          0          1
     schgt12 |      3343    .3356267    .4722797          0          1
        smsa |      3343    .7241998    .4469835          0          1
    bluecoll |      3343    .6036494     .489212          0          1
-------------+--------------------------------------------------------
      mining |      3343     .029315    .1687132          0          1
      constr |      3343    .1480706    .3552231          0          1
      transp |      3343    .0646126    .2458778          0          1
       trade |      3343    .1848639    .3882452          0          1
        fire |      3343    .0514508    .2209484          0          1
-------------+--------------------------------------------------------
    services |      3343    .1699073    .3756075          0          1
    pubadmin |      3343    .0095722     .097383          0          1
      year85 |      3343    .2677236     .442839          0          1
      year87 |      3343    .2174693    .4125862          0          1
      year89 |      3343    .1998205    .3999251          0          1
-------------+--------------------------------------------------------
      midatl |      3343    .1088842    .3115405          0          1
       encen |      3343    .1429853    .3501103          0          1
       wncen |      3343    .0643135    .2453472          0          1
    southatl |      3343    .2375112    .4256217          0          1
       escen |      3343    .0532456    .2245564          0          1
-------------+--------------------------------------------------------
       wscen |      3343    .1441819    .3513266          0          1
    mountain |      3343    .1079868    .3104102          0          1
     pacific |      3343    .0260245     .159232          0          1
          RR |      3343    .4544717    .1137918       .066      2.059
          DR |      3343    .1094376    .0735274       .002       1.02
-------------+--------------------------------------------------------
          UI |      3343    .5527969    .4972791          0          1
        RRUI |      3343    .2478687    .2380667          0      2.059
        DRUI |      3343    .0602776    .0754261          0       .824
     LOGWAGE |      3343    5.692994    .5356591    2.70805   7.600402

. 
. ********* COMPETING RISKS FOR UNEMPLOYMENT DURATION **********
. 
. * Stata analysis requires using stset to define the dependent variable
. * and the censoring variable if there is one
. 
. * For the competing risks model there are three censoring variables
. *  CENSOR1 = 1 if re-employed at full-time job
. *  CENSOR2 = 1 if re-employed at part-time job
. *  CENSOR3 = 1 if re-employed but left job: pt-ft status unknown
. 
. * Define $xlist = list of regressors used in subsequent regressions
. global xlist RR DR UI RRUI DRUI LOGWAGE /* 
>   */ tenure slack abolpos explose stateur houshead married /*
>   */ female child ychild nonwhite age schlt12 schgt12 smsa bluecoll /*
>   */ mining constr transp trade fire services pubadmin /*
>   */ year85 year87 year89 midatl /*
>   */ encen wncen southatl escen wscen mountain pacific

. 
. *** (1A) EXPONENTIAL WITH NO HETEROGENEITY  Table 19.2
. 
. stset spell, fail(censor1=1)

     failure event:  censor1 == 1
obs. time interval:  (0, spell]
 exit on or before:  failure

------------------------------------------------------------------------------
     3343  total obs.
        0  exclusions
------------------------------------------------------------------------------
     3343  obs. remaining, representing
     1073  failures in single record/single failure data
    20887  total analysis time at risk, at risk from t =         0
                             earliest observed entry t =         0
                                  last observed exit t =        28

. streg $xlist, nolog nohr robust dist(exponential)

         failure _d:  censor1 == 1
   analysis time _t:  spell

Exponential regression -- log relative-hazard form 

No. of subjects       =         3343               Number of obs   =      3343
No. of failures       =         1073
Time at risk          =        20887
                                                   Wald chi2(40)   =    565.24
Log pseudo-likelihood =   -2700.6903               Prob > chi2     =    0.0000

------------------------------------------------------------------------------
             |               Robust
          _t |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          RR |   .4720235   .6005534     0.79   0.432    -.7050396    1.649087
          DR |  -.5756396   .7624489    -0.75   0.450    -2.070012    .9187327
          UI |  -1.424561   .2493917    -5.71   0.000     -1.91336   -.9357622
        RRUI |   .9655904   .6118408     1.58   0.115    -.2335956    2.164776
        DRUI |  -.1990635   1.019118    -0.20   0.845    -2.196498    1.798371
     LOGWAGE |   .3508005    .115598     3.03   0.002     .1242327    .5773684
      tenure |  -.0001462   .0064637    -0.02   0.982    -.0128147    .0125224
       slack |  -.2593666   .0759363    -3.42   0.001    -.4081991   -.1105342
     abolpos |  -.1550897   .0953306    -1.63   0.104    -.3419342    .0317549
     explose |    .198458   .0648354     3.06   0.002      .071383    .3255331
     stateur |   -.064626   .0229903    -2.81   0.005    -.1096862   -.0195659
    houshead |   .3812208   .0836602     4.56   0.000     .2172499    .5451918
     married |    .369552   .0786145     4.70   0.000     .2154705    .5236335
      female |   .1164067   .0852986     1.36   0.172    -.0507754    .2835888
       child |  -.0333008   .0794577    -0.42   0.675    -.1890352    .1224335
      ychild |  -.1449722   .1022781    -1.42   0.156    -.3454336    .0554892
    nonwhite |  -.6692066   .1188272    -5.63   0.000    -.9021037   -.4363095
         age |  -.0220821   .0039256    -5.63   0.000    -.0297762   -.0143879
     schlt12 |  -.1231414   .0966102    -1.27   0.202    -.3124939     .066211
     schgt12 |   .1114395    .082945     1.34   0.179    -.0511297    .2740087
        smsa |   .1922291   .0799904     2.40   0.016     .0354508    .3490075
    bluecoll |  -.2033718    .085129    -2.39   0.017    -.3702215    -.036522
      mining |  -.1205818   .1973575    -0.61   0.541    -.5073955    .2662319
      constr |    -.04475   .1081519    -0.41   0.679    -.2567237    .1672238
      transp |  -.1786694    .156034    -1.15   0.252    -.4844906    .1271517
       trade |  -.0345159   .1019152    -0.34   0.735     -.234266    .1652341
        fire |   .1120549   .1386716     0.81   0.419    -.1597365    .3838462
    services |   .1840002   .0983911     1.87   0.061    -.0088428    .3768432
    pubadmin |   .1090606   .2954211     0.37   0.712    -.4699541    .6880752
      year85 |   .2147661   .0888664     2.42   0.016     .0405911     .388941
      year87 |   .3541162   .0948499     3.73   0.000     .1682139    .5400186
      year89 |    .467082   .1104355     4.23   0.000     .2506325    .6835316
      midatl |   .0264112   .1465647     0.18   0.857    -.2608503    .3136727
       encen |   .0043916   .1502813     0.03   0.977    -.2901544    .2989375
       wncen |   .1724311   .1607689     1.07   0.283    -.1426703    .4875324
    southatl |   .2638807   .1183726     2.23   0.026     .0318747    .4958867
       escen |     .35414     .19317     1.83   0.067    -.0244664    .7327463
       wscen |   .3385896   .1433308     2.36   0.018     .0576664    .6195128
    mountain |   .0063693   .1538821     0.04   0.967    -.2952341    .3079727
     pacific |   .0770202   .2393505     0.32   0.748    -.3920982    .5461385
       _cons |  -4.079107   .8767097    -4.65   0.000    -5.797426   -2.360788
------------------------------------------------------------------------------

. estimates store bexpr1

. 
. stset spell, fail(censor2=1)

     failure event:  censor2 == 1
obs. time interval:  (0, spell]
 exit on or before:  failure

------------------------------------------------------------------------------
     3343  total obs.
        0  exclusions
------------------------------------------------------------------------------
     3343  obs. remaining, representing
      339  failures in single record/single failure data
    20887  total analysis time at risk, at risk from t =         0
                             earliest observed entry t =         0
                                  last observed exit t =        28

. streg $xlist, nolog nohr robust dist(exponential)

         failure _d:  censor2 == 1
   analysis time _t:  spell

Exponential regression -- log relative-hazard form 

No. of subjects       =         3343               Number of obs   =      3343
No. of failures       =          339
Time at risk          =        20887
                                                   Wald chi2(40)   =    227.08
Log pseudo-likelihood =   -1250.5446               Prob > chi2     =    0.0000

------------------------------------------------------------------------------
             |               Robust
          _t |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          RR |  -.0928628   .9761428    -0.10   0.924    -2.006068    1.820342
          DR |  -.9600127   1.246692    -0.77   0.441    -3.403483    1.483458
          UI |  -1.047747   .5236826    -2.00   0.045    -2.074146    -.021348
        RRUI |  -.6698307   1.191869    -0.56   0.574    -3.005851    1.666189
        DRUI |   1.987208   1.726509     1.15   0.250    -1.396688    5.371105
     LOGWAGE |  -.2577715   .1793075    -1.44   0.151    -.6092077    .0936646
      tenure |   .0053684   .0125538     0.43   0.669    -.0192366    .0299734
       slack |  -.2636908   .1311029    -2.01   0.044    -.5206477   -.0067339
     abolpos |  -.5626836    .202701    -2.78   0.006    -.9599703   -.1653969
     explose |   .0490271   .1130116     0.43   0.664    -.1724715    .2705258
     stateur |  -.1032439   .0406788    -2.54   0.011     -.182973   -.0235148
    houshead |   -.073544   .1343412    -0.55   0.584    -.3368479      .18976
     married |  -.0618813   .1339552    -0.46   0.644    -.3244287    .2006661
      female |   .4531912   .1384047     3.27   0.001      .181923    .7244594
       child |  -.2164986   .1452571    -1.49   0.136    -.5011973    .0682002
      ychild |    .149031   .1815684     0.82   0.412    -.2068365    .5048986
    nonwhite |  -.4563527   .1820135    -2.51   0.012    -.8130927   -.0996127
         age |   -.001781   .0064207    -0.28   0.781    -.0143653    .0108033
     schlt12 |  -.1803101   .1661528    -1.09   0.278    -.5059636    .1453433
     schgt12 |  -.0534463   .1462829    -0.37   0.715    -.3401555    .2332629
        smsa |   .1295376   .1384588     0.94   0.349    -.1418367     .400912
    bluecoll |   .0088207   .1510547     0.06   0.953    -.2872411    .3048825
      mining |  -.0141252   .4078632    -0.03   0.972    -.8135225     .785272
      constr |   .1867498   .1896106     0.98   0.325    -.1848802    .5583799
      transp |   -.402533   .2898061    -1.39   0.165    -.9705426    .1654766
       trade |   .1106678   .1735195     0.64   0.524    -.2294241    .4507598
        fire |  -.3396026   .3006096    -1.13   0.259    -.9287865    .2495813
    services |   .1619867   .1705571     0.95   0.342     -.172299    .4962724
    pubadmin |   .7445446   .5413463     1.38   0.169    -.3164746    1.805564
      year85 |  -.0548375    .149323    -0.37   0.713    -.3475052    .2378301
      year87 |    -.12113   .1616797    -0.75   0.454    -.4380164    .1957563
      year89 |   .1244437   .1950397     0.64   0.523     -.257827    .5067144
      midatl |  -.3969537   .2577568    -1.54   0.124    -.9021477    .1082403
       encen |  -.5115788   .2576815    -1.99   0.047    -1.016625   -.0065323
       wncen |  -.0674875    .257402    -0.26   0.793    -.5719862    .4370113
    southatl |  -.2719375   .1944647    -1.40   0.162    -.6530813    .1092062
       escen |    .065407   .3099463     0.21   0.833    -.5420766    .6728905
       wscen |  -.0941963   .2338712    -0.40   0.687    -.5525754    .3641827
    mountain |   .2287682   .2264905     1.01   0.312     -.215145    .6726814
     pacific |  -.2060074   .3970221    -0.52   0.604    -.9841563    .5721415
       _cons |  -.8636363   1.325425    -0.65   0.515    -3.461421    1.734148
------------------------------------------------------------------------------

. estimates store bexpr2

. 
. stset spell, fail(censor3=1)

     failure event:  censor3 == 1
obs. time interval:  (0, spell]
 exit on or before:  failure

------------------------------------------------------------------------------
     3343  total obs.
        0  exclusions
------------------------------------------------------------------------------
     3343  obs. remaining, representing
      574  failures in single record/single failure data
    20887  total analysis time at risk, at risk from t =         0
                             earliest observed entry t =         0
                                  last observed exit t =        28

. streg $xlist, nolog nohr robust dist(exponential)

         failure _d:  censor3 == 1
   analysis time _t:  spell

Exponential regression -- log relative-hazard form 

No. of subjects       =         3343               Number of obs   =      3343
No. of failures       =          574
Time at risk          =        20887
                                                   Wald chi2(40)   =    372.34
Log pseudo-likelihood =   -1742.3964               Prob > chi2     =    0.0000

------------------------------------------------------------------------------
             |               Robust
          _t |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          RR |  -.6011551    .724665    -0.83   0.407    -2.021472    .8191621
          DR |   1.121525   .9012528     1.24   0.213    -.6448975    2.887948
          UI |  -.9672682   .4486302    -2.16   0.031    -1.846567   -.0879691
        RRUI |  -.4326869   1.014413    -0.43   0.670      -2.4209    1.555526
        DRUI |   2.102012   1.302564     1.61   0.107     -.450967    4.654991
     LOGWAGE |   .0029166   .1448149     0.02   0.984    -.2809153    .2867485
      tenure |  -.0479889   .0121403    -3.95   0.000    -.0717835   -.0241942
       slack |  -.4583215    .097709    -4.69   0.000    -.6498277   -.2668154
     abolpos |  -.2736409   .1396283    -1.96   0.050    -.5473073    .0000255
     explose |   .0246749   .0862551     0.29   0.775     -.144382    .1937319
     stateur |  -.1086692   .0319298    -3.40   0.001    -.1712504    -.046088
    houshead |   .5298135   .1054798     5.02   0.000     .3230769    .7365501
     married |   .0268657   .1062998     0.25   0.800    -.1814781    .2352095
      female |   .2590041    .109547     2.36   0.018     .0442959    .4737122
       child |   -.141802   .1114763    -1.27   0.203    -.3602915    .0766876
      ychild |  -.0885931    .136915    -0.65   0.518    -.3569416    .1797553
    nonwhite |  -.4668153    .143211    -3.26   0.001    -.7475036    -.186127
         age |  -.0247346   .0054431    -4.54   0.000    -.0354029   -.0140662
     schlt12 |  -.1034495   .1224893    -0.84   0.398    -.3435241    .1366251
     schgt12 |   .0952043   .1081669     0.88   0.379    -.1167988    .3072075
        smsa |   .0128711   .1021476     0.13   0.900    -.1873344    .2130767
    bluecoll |   .3098248   .1110841     2.79   0.005     .0921038    .5275457
      mining |   .2388579   .2604652     0.92   0.359    -.2716445    .7493603
      constr |   .0983356   .1419787     0.69   0.489    -.1799376    .3766088
      transp |  -.0783446   .1897853    -0.41   0.680    -.4503169    .2936278
       trade |   .1033278   .1292151     0.80   0.424    -.1499291    .3565847
        fire |  -.3607287   .2689374    -1.34   0.180    -.8878363     .166379
    services |   .0248212   .1323061     0.19   0.851     -.234494    .2841363
    pubadmin |  -1.770536   1.040329    -1.70   0.089    -3.809544    .2684714
      year85 |    .295673   .1143137     2.59   0.010     .0716222    .5197237
      year87 |   .4303606   .1198341     3.59   0.000     .1954901    .6652311
      year89 |  -.1373874   .1627204    -0.84   0.398    -.4563135    .1815386
      midatl |  -.5339921   .2188609    -2.44   0.015    -.9629516   -.1050326
       encen |   -.075022   .1998626    -0.38   0.707    -.4667454    .3167014
       wncen |   .1239805   .2095321     0.59   0.554    -.2866948    .5346559
    southatl |   .1522514   .1635982     0.93   0.352    -.1683951     .472898
       escen |  -.5123015   .3170723    -1.62   0.106    -1.133752    .1091488
       wscen |   .0198459   .1898764     0.10   0.917    -.3523051    .3919968
    mountain |   .1999108   .1869463     1.07   0.285    -.1664972    .5663188
     pacific |   .4481059   .2705097     1.66   0.098    -.0820833    .9782951
       _cons |  -1.620926   1.072666    -1.51   0.131    -3.723312    .4814595
------------------------------------------------------------------------------

. estimates store bexpr3

. 
. * Table 19.2 (page 658) first three columns
. estimates table bexpr1 bexpr2 bexpr3, b(%10.3f) se(%10.3f) stats(N ll) /*
>  */ keep(RR DR UI RRUI DRUI LOGWAGE tenure)

-----------------------------------------------------
    Variable |   bexpr1       bexpr2       bexpr3    
-------------+---------------------------------------
          RR |      0.472       -0.093       -0.601  
             |      0.601        0.976        0.725  
          DR |     -0.576       -0.960        1.122  
             |      0.762        1.247        0.901  
          UI |     -1.425       -1.048       -0.967  
             |      0.249        0.524        0.449  
        RRUI |      0.966       -0.670       -0.433  
             |      0.612        1.192        1.014  
        DRUI |     -0.199        1.987        2.102  
             |      1.019        1.727        1.303  
     LOGWAGE |      0.351       -0.258        0.003  
             |      0.116        0.179        0.145  
      tenure |     -0.000        0.005       -0.048  
             |      0.006        0.013        0.012  
-------------+---------------------------------------
           N |   3343.000     3343.000     3343.000  
          ll |  -2700.690    -1250.545    -1742.396  
-----------------------------------------------------
                                         legend: b/se

. 
. *** (1B) EXPONENTIAL WITH IG HETEROGENEITY  Table 19.2
. 
. /* Did not work even though Weibull with IG heterogeneity did
> 
> stset spell, fail(censor1=1)
> streg $xlist, nohr robust dist(exponential) frailty(invgauss)
> estimates store bexpigr1
> 
> stset spell, fail(censor2=1)
> streg $xlist, nolog nohr robust dist(exponential) frailty(invgauss)
> estimates store bexpigr2
> 
> stset spell, fail(censor3=1)
> streg $xlist, nolog nohr robust dist(exponential)
> estimates store bexpiggr3
> 
> * Table 19.2 (page 658) first three columns
> estimates table bexpigr1 bexpigr2 bexpigr3, b(%10.3f) se(%10.3f) stats(N ll) /*
>  */ keep(RR DR UI RRUI DRUI LOGWAGE tenure)
> 
> */
. 
. *** (2A) WEIBULL WITH NO HETEROGENEITY  Table 19.3
. 
. stset spell, fail(censor1=1)

     failure event:  censor1 == 1
obs. time interval:  (0, spell]
 exit on or before:  failure

------------------------------------------------------------------------------
     3343  total obs.
        0  exclusions
------------------------------------------------------------------------------
     3343  obs. remaining, representing
     1073  failures in single record/single failure data
    20887  total analysis time at risk, at risk from t =         0
                             earliest observed entry t =         0
                                  last observed exit t =        28

. streg $xlist, nolog nohr robust dist(weibull) 

         failure _d:  censor1 == 1
   analysis time _t:  spell

Weibull regression -- log relative-hazard form 

No. of subjects       =         3343               Number of obs   =      3343
No. of failures       =         1073
Time at risk          =        20887
                                                   Wald chi2(40)   =    501.65
Log pseudo-likelihood =   -2687.5995               Prob > chi2     =    0.0000

------------------------------------------------------------------------------
             |               Robust
          _t |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          RR |   .4481156   .6381895     0.70   0.483    -.8027127    1.698944
          DR |  -.4269187   .8086983    -0.53   0.598    -2.011938    1.158101
          UI |  -1.496066   .2639679    -5.67   0.000    -2.013434   -.9786984
        RRUI |   1.015226   .6455611     1.57   0.116    -.2500501    2.280503
        DRUI |  -.2988417   1.065384    -0.28   0.779    -2.386956    1.789272
     LOGWAGE |   .3655253     .12212     2.99   0.003     .1261745    .6048761
      tenure |  -.0011127   .0068716    -0.16   0.871    -.0145809    .0123554
       slack |  -.2652154   .0803214    -3.30   0.001    -.4226424   -.1077883
     abolpos |  -.1604227   .1012942    -1.58   0.113    -.3589557    .0381103
     explose |   .2075085   .0684715     3.03   0.002     .0733068    .3417103
     stateur |  -.0708745   .0242117    -2.93   0.003    -.1183286   -.0234204
    houshead |   .3976626   .0887192     4.48   0.000     .2237762     .571549
     married |   .3786057   .0830317     4.56   0.000     .2158665     .541345
      female |   .1260829   .0896987     1.41   0.160    -.0497233     .301889
       child |  -.0336778   .0839956    -0.40   0.688    -.1983061    .1309505
      ychild |  -.1613066    .108947    -1.48   0.139    -.3748389    .0522256
    nonwhite |  -.7025504     .12426    -5.65   0.000    -.9460956   -.4590052
         age |  -.0235823   .0041922    -5.63   0.000    -.0317989   -.0153658
     schlt12 |  -.1226759   .1022762    -1.20   0.230    -.3231335    .0777816
     schgt12 |   .1162848   .0880692     1.32   0.187    -.0563278    .2888973
        smsa |   .1999567   .0841129     2.38   0.017     .0350985    .3648149
    bluecoll |  -.1994925   .0899354    -2.22   0.027    -.3757626   -.0232223
      mining |  -.1015676   .2036644    -0.50   0.618    -.5007425    .2976073
      constr |  -.0253737   .1135609    -0.22   0.823     -.247949    .1972016
      transp |  -.1981522   .1672141    -1.19   0.236    -.5258858    .1295814
       trade |  -.0311361   .1079502    -0.29   0.773    -.2427146    .1804423
        fire |   .1262153   .1492527     0.85   0.398    -.1663145    .4187452
    services |   .2031673   .1038945     1.96   0.051    -.0004622    .4067968
    pubadmin |   .1117728   .3087374     0.36   0.717    -.4933415     .716887
      year85 |   .2374972    .093387     2.54   0.011      .054462    .4205325
      year87 |   .3787397   .1011782     3.74   0.000     .1804341    .5770454
      year89 |   .4920278   .1180472     4.17   0.000     .2606596    .7233959
      midatl |     .02465   .1542139     0.16   0.873    -.2776037    .3269036
       encen |  -.0014111   .1579065    -0.01   0.993    -.3109023      .30808
       wncen |   .1844363   .1694444     1.09   0.276    -.1476687    .5165413
    southatl |   .2740974   .1250481     2.19   0.028     .0290076    .5191872
       escen |    .367742   .2024771     1.82   0.069    -.0291058    .7645899
       wscen |   .3440005   .1527804     2.25   0.024     .0445563    .6434446
    mountain |   .0159627   .1620188     0.10   0.922    -.3015883    .3335136
     pacific |   .0849532   .2504077     0.34   0.734    -.4058368    .5757432
       _cons |  -4.357886   .9196792    -4.74   0.000    -6.160424   -2.555347
-------------+----------------------------------------------------------------
       /ln_p |   .1215314   .0194374     6.25   0.000     .0834348    .1596281
-------------+----------------------------------------------------------------
           p |   1.129225   .0219492                      1.087014    1.173075
         1/p |   .8855632   .0172131                      .8524608    .9199511
------------------------------------------------------------------------------

. estimates store bweibr1

. 
. stset spell, fail(censor2=1)

     failure event:  censor2 == 1
obs. time interval:  (0, spell]
 exit on or before:  failure

------------------------------------------------------------------------------
     3343  total obs.
        0  exclusions
------------------------------------------------------------------------------
     3343  obs. remaining, representing
      339  failures in single record/single failure data
    20887  total analysis time at risk, at risk from t =         0
                             earliest observed entry t =         0
                                  last observed exit t =        28

. streg $xlist, nolog nohr robust dist(weibull)

         failure _d:  censor2 == 1
   analysis time _t:  spell

Weibull regression -- log relative-hazard form 

No. of subjects       =         3343               Number of obs   =      3343
No. of failures       =          339
Time at risk          =        20887
                                                   Wald chi2(40)   =    222.95
Log pseudo-likelihood =   -1248.6859               Prob > chi2     =    0.0000

------------------------------------------------------------------------------
             |               Robust
          _t |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          RR |  -.0855974   .9920715    -0.09   0.931    -2.030022    1.858827
          DR |  -.9387836   1.279111    -0.73   0.463    -3.445794    1.568227
          UI |  -1.110175   .5267037    -2.11   0.035    -2.142496   -.0778551
        RRUI |  -.6171912   1.203735    -0.51   0.608    -2.976469    1.742086
        DRUI |   1.973269   1.756599     1.12   0.261    -1.469601     5.41614
     LOGWAGE |  -.2437885   .1833224    -1.33   0.184    -.6030938    .1155168
      tenure |   .0050643   .0127387     0.40   0.691    -.0199031    .0300317
       slack |  -.2689689    .133176    -2.02   0.043     -.529989   -.0079487
     abolpos |  -.5721689   .2059292    -2.78   0.005    -.9757826   -.1685551
     explose |   .0555267   .1147555     0.48   0.628      -.16939    .2804433
     stateur |  -.1087083   .0413647    -2.63   0.009    -.1897816    -.027635
    houshead |  -.0679894     .13661    -0.50   0.619    -.3357401    .1997613
     married |   -.060856   .1362403    -0.45   0.655     -.327882      .20617
      female |   .4583892   .1408831     3.25   0.001     .1822634     .734515
       child |  -.2228982    .147376    -1.51   0.130    -.5117499    .0659535
      ychild |   .1463598   .1844362     0.79   0.427    -.2151284     .507848
    nonwhite |   -.485664    .186033    -2.61   0.009    -.8502819    -.121046
         age |  -.0027009   .0065569    -0.41   0.680    -.0155521    .0101503
     schlt12 |  -.1837633   .1684487    -1.09   0.275    -.5139167    .1463901
     schgt12 |  -.0488958   .1485385    -0.33   0.742     -.340026    .2422343
        smsa |   .1380042   .1410747     0.98   0.328    -.1384971    .4145055
    bluecoll |   .0132584   .1537386     0.09   0.931    -.2880637    .3145805
      mining |  -.0138734   .4110202    -0.03   0.973    -.8194583    .7917115
      constr |   .1973771   .1920481     1.03   0.304    -.1790303    .5737845
      transp |  -.4116241   .2927848    -1.41   0.160    -.9854717    .1622234
       trade |   .1125741   .1765277     0.64   0.524    -.2334139    .4585621
        fire |  -.3378747   .3046641    -1.11   0.267    -.9350054    .2592561
    services |   .1700335   .1729565     0.98   0.326    -.1689551    .5090221
    pubadmin |   .7553679   .5487635     1.38   0.169    -.3201889    1.830925
      year85 |  -.0501695   .1515048    -0.33   0.741    -.3471135    .2467745
      year87 |  -.1116858   .1645254    -0.68   0.497    -.4341497    .2107781
      year89 |   .1344555   .1987084     0.68   0.499    -.2550059    .5239168
      midatl |  -.4039691   .2606153    -1.55   0.121    -.9147658    .1068276
       encen |  -.5105877   .2608364    -1.96   0.050    -1.021818    .0006423
       wncen |  -.0579723   .2607792    -0.22   0.824    -.5690902    .4531456
    southatl |  -.2682241   .1972983    -1.36   0.174    -.6549216    .1184733
       escen |    .079807   .3146812     0.25   0.800    -.5369568    .6965709
       wscen |  -.0854421   .2368638    -0.36   0.718    -.5496865    .3788024
    mountain |   .2441762   .2300886     1.06   0.289    -.2067892    .6951416
     pacific |  -.1999107   .4003467    -0.50   0.618    -.9845758    .5847544
       _cons |  -1.055211   1.353275    -0.78   0.436    -3.707582    1.597159
-------------+----------------------------------------------------------------
       /ln_p |   .0815649   .0308379     2.64   0.008     .0211236    .1420061
-------------+----------------------------------------------------------------
           p |   1.084984   .0334587                      1.021348    1.152584
         1/p |   .9216729   .0284225                      .8676159    .9790979
------------------------------------------------------------------------------

. estimates store bweibr2

. 
. stset spell, fail(censor3=1)

     failure event:  censor3 == 1
obs. time interval:  (0, spell]
 exit on or before:  failure

------------------------------------------------------------------------------
     3343  total obs.
        0  exclusions
------------------------------------------------------------------------------
     3343  obs. remaining, representing
      574  failures in single record/single failure data
    20887  total analysis time at risk, at risk from t =         0
                             earliest observed entry t =         0
                                  last observed exit t =        28

. streg $xlist, nolog nohr robust dist(weibull)

         failure _d:  censor3 == 1
   analysis time _t:  spell

Weibull regression -- log relative-hazard form 

No. of subjects       =         3343               Number of obs   =      3343
No. of failures       =          574
Time at risk          =        20887
                                                   Wald chi2(40)   =    350.72
Log pseudo-likelihood =   -1729.8356               Prob > chi2     =    0.0000

------------------------------------------------------------------------------
             |               Robust
          _t |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          RR |  -.6946399    .762754    -0.91   0.362     -2.18961    .8003305
          DR |   1.361414   .9691375     1.40   0.160    -.5380611    3.260888
          UI |  -1.098453   .4595297    -2.39   0.017    -1.999115   -.1977918
        RRUI |  -.3055217   1.046769    -0.29   0.770    -2.357151    1.746107
        DRUI |   1.990913    1.37004     1.45   0.146    -.6943156    4.676141
     LOGWAGE |   .0401096   .1526549     0.26   0.793    -.2590886    .3393078
      tenure |  -.0495153   .0126559    -3.91   0.000    -.0743204   -.0247103
       slack |   -.473113   .1025776    -4.61   0.000    -.6741614   -.2720647
     abolpos |  -.2910168   .1465355    -1.99   0.047    -.5782212   -.0038124
     explose |   .0315602   .0906338     0.35   0.728    -.1460787    .2091991
     stateur |  -.1199252   .0337488    -3.55   0.000    -.1860717   -.0537787
    houshead |   .5592843   .1107798     5.05   0.000     .3421598    .7764087
     married |    .032312   .1115613     0.29   0.772    -.1863442    .2509681
      female |   .2764899   .1147909     2.41   0.016     .0515039    .5014759
       child |   -.149619   .1167679    -1.28   0.200    -.3784799     .079242
      ychild |  -.1018703   .1436607    -0.71   0.478    -.3834401    .1796996
    nonwhite |  -.5164388   .1517355    -3.40   0.001    -.8138349   -.2190427
         age |  -.0275549   .0057648    -4.78   0.000    -.0388536   -.0162561
     schlt12 |  -.1115642   .1291366    -0.86   0.388    -.3646673    .1415389
     schgt12 |   .1015553   .1135108     0.89   0.371    -.1209217    .3240324
        smsa |   .0270168   .1078739     0.25   0.802    -.1844122    .2384459
    bluecoll |   .3229431   .1167884     2.77   0.006      .094042    .5518443
      mining |   .2437267   .2731206     0.89   0.372    -.2915799    .7790332
      constr |   .1307943   .1484399     0.88   0.378    -.1601425    .4217311
      transp |  -.1004424   .2004105    -0.50   0.616    -.4932397    .2923549
       trade |   .1181562    .136055     0.87   0.385    -.1485068    .3848192
        fire |   -.344603   .2792784    -1.23   0.217    -.8919787    .2027726
    services |   .0519644   .1386656     0.37   0.708    -.2198151    .3237438
    pubadmin |  -1.780582   1.049217    -1.70   0.090    -3.837009    .2758459
      year85 |    .311726   .1192592     2.61   0.009     .0779822    .5454698
      year87 |   .4514345    .126241     3.58   0.000     .2040067    .6988623
      year89 |  -.1180122   .1713414    -0.69   0.491    -.4538352    .2178108
      midatl |  -.5476552    .224463    -2.44   0.015    -.9875945   -.1077158
       encen |   -.084084     .20745    -0.41   0.685    -.4906786    .3225106
       wncen |   .1288938   .2191536     0.59   0.556    -.3006393    .5584268
    southatl |     .16223   .1702456     0.95   0.341    -.1714454    .4959053
       escen |  -.5110545   .3270884    -1.56   0.118    -1.152136     .130027
       wscen |   .0218047   .1978693     0.11   0.912    -.3660121    .4096214
    mountain |   .2045852   .1949939     1.05   0.294    -.1775957    .5867662
     pacific |   .4535074   .2840292     1.60   0.110    -.1031795    1.010194
       _cons |  -2.017592   1.123888    -1.80   0.073    -4.220372    .1851884
-------------+----------------------------------------------------------------
       /ln_p |    .163312   .0235045     6.95   0.000      .117244    .2093801
-------------+----------------------------------------------------------------
           p |   1.177404   .0276744                      1.124394    1.232914
         1/p |   .8493261    .019963                      .8110869    .8893682
------------------------------------------------------------------------------

. estimates store bweibr3

. 
. * Table 19.3 (page 659) first three columns
. estimates table bweibr1 bweibr2 bweibr3, b(%10.3f) se(%10.3f) stats(N ll) /*
>  */ keep(RR DR UI RRUI DRUI LOGWAGE tenure)

-----------------------------------------------------
    Variable |  bweibr1      bweibr2      bweibr3    
-------------+---------------------------------------
          RR |      0.448       -0.086       -0.695  
             |      0.638        0.992        0.763  
          DR |     -0.427       -0.939        1.361  
             |      0.809        1.279        0.969  
          UI |     -1.496       -1.110       -1.098  
             |      0.264        0.527        0.460  
        RRUI |      1.015       -0.617       -0.306  
             |      0.646        1.204        1.047  
        DRUI |     -0.299        1.973        1.991  
             |      1.065        1.757        1.370  
     LOGWAGE |      0.366       -0.244        0.040  
             |      0.122        0.183        0.153  
      tenure |     -0.001        0.005       -0.050  
             |      0.007        0.013        0.013  
-------------+---------------------------------------
           N |   3343.000     3343.000     3343.000  
          ll |  -2687.600    -1248.686    -1729.836  
-----------------------------------------------------
                                         legend: b/se

. 
. *** (2B) WEIBULL WITH IG HETEROGENEITY  Table 19.3
. 
. stset spell, fail(censor1=1)

     failure event:  censor1 == 1
obs. time interval:  (0, spell]
 exit on or before:  failure

------------------------------------------------------------------------------
     3343  total obs.
        0  exclusions
------------------------------------------------------------------------------
     3343  obs. remaining, representing
     1073  failures in single record/single failure data
    20887  total analysis time at risk, at risk from t =         0
                             earliest observed entry t =         0
                                  last observed exit t =        28

. streg $xlist, nohr robust dist(weibull) frailty(invgauss)

         failure _d:  censor1 == 1
   analysis time _t:  spell

Fitting weibull model:

Fitting constant-only model:

Iteration 0:   log pseudo-likelihood = -3134.2376  (not concave)
Iteration 1:   log pseudo-likelihood =  -2998.472  
Iteration 2:   log pseudo-likelihood = -2984.8299  
Iteration 3:   log pseudo-likelihood = -2960.0446  
Iteration 4:   log pseudo-likelihood = -2954.9102  
Iteration 5:   log pseudo-likelihood = -2954.8838  
Iteration 6:   log pseudo-likelihood = -2954.8838  

Fitting full model:

Iteration 0:   log pseudo-likelihood = -2656.6306  
Iteration 1:   log pseudo-likelihood =  -2632.196  
Iteration 2:   log pseudo-likelihood = -2616.9139  
Iteration 3:   log pseudo-likelihood = -2616.3231  
Iteration 4:   log pseudo-likelihood = -2616.3216  
Iteration 5:   log pseudo-likelihood = -2616.3216  

Weibull regression -- log relative-hazard form 
                      Inverse-Gaussian frailty

No. of subjects       =         3343               Number of obs   =      3343
No. of failures       =         1073
Time at risk          =        20887
                                                   Wald chi2(40)   =    643.00
Log pseudo-likelihood =   -2616.3216               Prob > chi2     =    0.0000

------------------------------------------------------------------------------
             |               Robust
          _t |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          RR |   .7356277   .9058181     0.81   0.417    -1.039743    2.510998
          DR |  -1.072566   1.149098    -0.93   0.351    -3.324758    1.179625
          UI |  -2.574752   .3843798    -6.70   0.000    -3.328123   -1.821381
        RRUI |   1.733571   .9333928     1.86   0.063    -.0958458    3.562987
        DRUI |   -.060621   1.537813    -0.04   0.969     -3.07468    2.953438
     LOGWAGE |    .575656   .1766599     3.26   0.001     .2294089    .9219031
      tenure |  -.0009848   .0097472    -0.10   0.920    -.0200889    .0181194
       slack |  -.4416007   .1142976    -3.86   0.000    -.6656199   -.2175814
     abolpos |  -.2873066   .1465357    -1.96   0.050    -.5745113   -.0001019
     explose |   .3641943   .0976897     3.73   0.000     .1727259    .5556627
     stateur |  -.0981133   .0346763    -2.83   0.005    -.1660775    -.030149
    houshead |   .5924383   .1256739     4.71   0.000     .3461219    .8387546
     married |   .6083214   .1183487     5.14   0.000     .3763624    .8402805
      female |   .1788439   .1285074     1.39   0.164    -.0730259    .4307137
       child |  -.0914227    .121778    -0.75   0.453    -.3301031    .1472578
      ychild |  -.1805373   .1527477    -1.18   0.237    -.4799173    .1188426
    nonwhite |  -1.008517   .1725174    -5.85   0.000    -1.346645   -.6703894
         age |  -.0333776   .0059183    -5.64   0.000    -.0449772   -.0217779
     schlt12 |  -.2258621   .1439543    -1.57   0.117    -.5080075    .0562832
     schgt12 |   .1505129    .124469     1.21   0.227    -.0934418    .3944677
        smsa |   .3009952    .119907     2.51   0.012     .0659819    .5360086
    bluecoll |  -.3211857   .1253163    -2.56   0.010    -.5668012   -.0755702
      mining |  -.2319827   .3008491    -0.77   0.441    -.8216361    .3576708
      constr |  -.1260324   .1633669    -0.77   0.440    -.4462257    .1941609
      transp |  -.2763858    .225893    -1.22   0.221    -.7191279    .1663562
       trade |  -.0687616   .1518284    -0.45   0.651    -.3663399    .2288166
        fire |   .0668973   .2131814     0.31   0.754    -.3509306    .4847252
    services |    .231914   .1494712     1.55   0.121    -.0610441    .5248721
    pubadmin |   .0901949   .4579252     0.20   0.844     -.807322    .9877117
      year85 |   .2780139   .1339053     2.08   0.038     .0155644    .5404634
      year87 |   .5208783   .1415375     3.68   0.000     .2434699    .7982867
      year89 |   .7209598   .1655487     4.35   0.000     .3964903    1.045429
      midatl |  -.0192077   .2222646    -0.09   0.931    -.4548382    .4164228
       encen |  -.0297055   .2284931    -0.13   0.897    -.4775438    .4181328
       wncen |   .2460338     .24216     1.02   0.310    -.2285911    .7206586
    southatl |   .3563643   .1793284     1.99   0.047     .0048872    .7078415
       escen |   .5461543   .2910193     1.88   0.061     -.024233    1.116542
       wscen |   .4606814   .2140966     2.15   0.031     .0410598     .880303
    mountain |    .017581   .2293804     0.08   0.939    -.4319963    .4671584
     pacific |   .1379886   .3636985     0.38   0.704    -.5748475    .8508247
       _cons |  -5.303059    1.34133    -3.95   0.000    -7.932017     -2.6741
-------------+----------------------------------------------------------------
       /ln_p |   .5611667   .0225898    24.84   0.000     .5168915    .6054418
     /ln_the |   1.852696   .0896755    20.66   0.000     1.676935    2.028457
-------------+----------------------------------------------------------------
           p |   1.752716   .0395935                      1.676807    1.832062
         1/p |    .570543   .0128884                      .5458332    .5963715
       theta |   6.376987   .5718595                      5.349136    7.602343
------------------------------------------------------------------------------

. estimates store bweibigr1

. 
. stset spell, fail(censor2=1)

     failure event:  censor2 == 1
obs. time interval:  (0, spell]
 exit on or before:  failure

------------------------------------------------------------------------------
     3343  total obs.
        0  exclusions
------------------------------------------------------------------------------
     3343  obs. remaining, representing
      339  failures in single record/single failure data
    20887  total analysis time at risk, at risk from t =         0
                             earliest observed entry t =         0
                                  last observed exit t =        28

. streg $xlist, nolog nohr robust dist(weibull) frailty(invgauss)

         failure _d:  censor2 == 1
   analysis time _t:  spell

Weibull regression -- log relative-hazard form 
                      Inverse-Gaussian frailty

No. of subjects       =         3343               Number of obs   =      3343
No. of failures       =          339
Time at risk          =        20887
                                                   Wald chi2(40)   =    253.77
Log pseudo-likelihood =   -1230.1643               Prob > chi2     =    0.0000

------------------------------------------------------------------------------
             |               Robust
          _t |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          RR |  -.3802006   1.452095    -0.26   0.793    -3.226255    2.465854
          DR |  -1.689504   1.779553    -0.95   0.342    -5.177363    1.798355
          UI |  -2.063963   .7469659    -2.76   0.006    -3.527989   -.5999369
        RRUI |  -.3019038   1.702153    -0.18   0.859    -3.638063    3.034255
        DRUI |   3.263067   2.469908     1.32   0.186    -1.577863    8.103998
     LOGWAGE |  -.4954862   .2614747    -1.89   0.058    -1.007967    .0169948
      tenure |   .0174014   .0192239     0.91   0.365    -.0202768    .0550795
       slack |  -.3889861   .1911789    -2.03   0.042    -.7636898   -.0142824
     abolpos |  -.8027208   .2877528    -2.79   0.005    -1.366706   -.2387356
     explose |   .1187808   .1663987     0.71   0.475    -.2073546    .4449162
     stateur |  -.1753726    .059272    -2.96   0.003    -.2915437   -.0592015
    houshead |  -.0832153   .1944376    -0.43   0.669     -.464306    .2978754
     married |  -.0092249   .1945187    -0.05   0.962    -.3904747    .3720248
      female |   .6284921   .2064768     3.04   0.002      .223805    1.033179
       child |   -.389325   .2127697    -1.83   0.067     -.806346    .0276959
      ychild |   .3144939   .2663886     1.18   0.238    -.2076182     .836606
    nonwhite |  -.6691885   .2633831    -2.54   0.011     -1.18541   -.1529671
         age |  -.0034533   .0093696    -0.37   0.712    -.0218174    .0149108
     schlt12 |  -.3242365   .2380109    -1.36   0.173    -.7907293    .1422562
     schgt12 |  -.0745655   .2138285    -0.35   0.727    -.4936618    .3445307
        smsa |   .2107394   .2012744     1.05   0.295    -.1837512      .60523
    bluecoll |  -.0065426   .2175612    -0.03   0.976    -.4329548    .4198696
      mining |   .1293103   .6093175     0.21   0.832     -1.06493    1.323551
      constr |   .2870954   .2728176     1.05   0.293    -.2476172    .8218081
      transp |  -.6470251   .4118414    -1.57   0.116    -1.454219    .1601692
       trade |   .1901489   .2529975     0.75   0.452    -.3057172    .6860149
        fire |  -.4680763   .4488502    -1.04   0.297    -1.347807     .411654
    services |   .2462185   .2531429     0.97   0.331    -.2499325    .7423696
    pubadmin |   1.351206   .7621665     1.77   0.076    -.1426127    2.845025
      year85 |  -.1501166   .2195046    -0.68   0.494    -.5803377    .2801044
      year87 |  -.2400145    .236954    -1.01   0.311    -.7044358    .2244069
      year89 |   .1828811   .2831188     0.65   0.518    -.3720216    .7377838
      midatl |  -.4074373   .3806192    -1.07   0.284    -1.153437    .3385627
       encen |  -.6525035    .381508    -1.71   0.087    -1.400245    .0952385
       wncen |  -.1300751   .3835973    -0.34   0.735    -.8819119    .6217617
    southatl |  -.3491396   .2954776    -1.18   0.237     -.928265    .2299859
       escen |   .2960895   .4558667     0.65   0.516    -.5973927    1.189572
       wscen |  -.0903554   .3527441    -0.26   0.798    -.7817212    .6010104
    mountain |   .3721587   .3457717     1.08   0.282    -.3055413    1.049859
     pacific |  -.1996218   .6042626    -0.33   0.741    -1.383955    .9847112
       _cons |   1.157635   1.957298     0.59   0.554    -2.678599    4.993869
-------------+----------------------------------------------------------------
       /ln_p |   .5004283   .0361284    13.85   0.000      .429618    .5712386
     /ln_the |   2.896807   .1749249    16.56   0.000      2.55396    3.239653
-------------+----------------------------------------------------------------
           p |   1.649428   .0595911                       1.53667    1.770459
         1/p |   .6062709   .0219036                      .5648254    .6507577
       theta |   18.11621   3.168976                      12.85793    25.52487
------------------------------------------------------------------------------

. estimates store bweibigr2

. 
. stset spell, fail(censor3=1)

     failure event:  censor3 == 1
obs. time interval:  (0, spell]
 exit on or before:  failure

------------------------------------------------------------------------------
     3343  total obs.
        0  exclusions
------------------------------------------------------------------------------
     3343  obs. remaining, representing
      574  failures in single record/single failure data
    20887  total analysis time at risk, at risk from t =         0
                             earliest observed entry t =         0
                                  last observed exit t =        28

. streg $xlist, nolog nohr robust dist(weibull) frailty(invgauss)

         failure _d:  censor3 == 1
   analysis time _t:  spell

Weibull regression -- log relative-hazard form 
                      Inverse-Gaussian frailty

No. of subjects       =         3343               Number of obs   =      3343
No. of failures       =          574
Time at risk          =        20887
                                                   Wald chi2(40)   =    416.91
Log pseudo-likelihood =   -1696.8456               Prob > chi2     =    0.0000

------------------------------------------------------------------------------
             |               Robust
          _t |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          RR |  -.4326716   1.111223    -0.39   0.697    -2.610628    1.745285
          DR |   1.166629   1.377826     0.85   0.397    -1.533861    3.867119
          UI |  -1.761667    .623017    -2.83   0.005    -2.982758   -.5405758
        RRUI |  -.5160276   1.418361    -0.36   0.716    -3.295964    2.263909
        DRUI |   3.668779    1.93489     1.90   0.058    -.1235355    7.461093
     LOGWAGE |  -.0069584   .2162461    -0.03   0.974    -.4307929    .4168762
      tenure |  -.0677151   .0174959    -3.87   0.000    -.1020065   -.0334237
       slack |  -.7093182    .145145    -4.89   0.000    -.9937971   -.4248392
     abolpos |  -.4327781   .2106818    -2.05   0.040    -.8457069   -.0198494
     explose |   .0930879   .1284587     0.72   0.469    -.1586864    .3448623
     stateur |  -.1684826   .0472936    -3.56   0.000    -.2611764   -.0757887
    houshead |   .7760519   .1555864     4.99   0.000     .4711081    1.080996
     married |   .0849334   .1585652     0.54   0.592    -.2258487    .3957154
      female |    .329107   .1637254     2.01   0.044     .0082111    .6500028
       child |  -.2734744   .1667453    -1.64   0.101    -.6002892    .0533403
      ychild |   -.101407   .2021952    -0.50   0.616    -.4977024    .2948883
    nonwhite |  -.7325977    .211777    -3.46   0.001    -1.147673   -.3175223
         age |  -.0354358    .007992    -4.43   0.000    -.0510998   -.0197719
     schlt12 |  -.1729163   .1803828    -0.96   0.338    -.5264602    .1806275
     schgt12 |   .0955174   .1615133     0.59   0.554    -.2210429    .4120777
        smsa |   .0225321   .1500451     0.15   0.881    -.2715509    .3166151
    bluecoll |   .4311626   .1651405     2.61   0.009     .1074931    .7548321
      mining |   .4464055   .3724328     1.20   0.231    -.2835495     1.17636
      constr |   .1875875   .2104018     0.89   0.373    -.2247926    .5999675
      transp |  -.0190191   .2877627    -0.07   0.947    -.5830237    .5449855
       trade |   .1708654   .1960546     0.87   0.383    -.2133945    .5551253
        fire |  -.3548846   .3851005    -0.92   0.357    -1.109668    .3998985
    services |   .0199891   .1978478     0.10   0.920    -.3677854    .4077636
    pubadmin |  -2.249289   1.450209    -1.55   0.121    -5.091646    .5930688
      year85 |   .3978277   .1726143     2.30   0.021     .0595099    .7361456
      year87 |   .6809662   .1807412     3.77   0.000       .32672    1.035212
      year89 |  -.1380237   .2307311    -0.60   0.550    -.5902485     .314201
      midatl |  -.7908245   .3280754    -2.41   0.016     -1.43384   -.1478085
       encen |  -.1035781   .2984816    -0.35   0.729    -.6885913    .4814351
       wncen |   .2578004   .3150731     0.82   0.413    -.3597316    .8753324
    southatl |   .2314723   .2430344     0.95   0.341    -.2448663    .7078109
       escen |  -.6777305   .4486486    -1.51   0.131    -1.557065    .2016045
       wscen |   .0308173   .2842933     0.11   0.914    -.5263874    .5880219
    mountain |   .2849032   .2816226     1.01   0.312     -.267067    .8368734
     pacific |   .7162217   .4103619     1.75   0.081    -.0880727    1.520516
       _cons |   -1.42279   1.617429    -0.88   0.379    -4.592894    1.747313
-------------+----------------------------------------------------------------
       /ln_p |   .5795747    .026888    21.56   0.000     .5268752    .6322742
     /ln_the |   2.262575   .1322516    17.11   0.000     2.003367    2.521783
-------------+----------------------------------------------------------------
           p |   1.785279   .0480026                      1.693632    1.881886
         1/p |   .5601365   .0150609                      .5313819    .5904471
       theta |   9.607798   1.270647                      7.413974    12.45078
------------------------------------------------------------------------------

. estimates store bweibigr3

. 
. * Table 19.3 (page 659) first three columns
. estimates table bweibigr1 bweibigr2 bweibigr3, b(%10.3f) se(%10.3f) stats(N ll) /*
>  */ keep(RR DR UI RRUI DRUI LOGWAGE tenure)

-----------------------------------------------------
    Variable | bweibigr1    bweibigr2    bweibigr3   
-------------+---------------------------------------
          RR |      0.736       -0.380       -0.433  
             |      0.906        1.452        1.111  
          DR |     -1.073       -1.690        1.167  
             |      1.149        1.780        1.378  
          UI |     -2.575       -2.064       -1.762  
             |      0.384        0.747        0.623  
        RRUI |      1.734       -0.302       -0.516  
             |      0.933        1.702        1.418  
        DRUI |     -0.061        3.263        3.669  
             |      1.538        2.470        1.935  
     LOGWAGE |      0.576       -0.495       -0.007  
             |      0.177        0.261        0.216  
      tenure |     -0.001        0.017       -0.068  
             |      0.010        0.019        0.017  
-------------+---------------------------------------
           N |   3343.000     3343.000     3343.000  
          ll |  -2616.322    -1230.164    -1696.846  
-----------------------------------------------------
                                         legend: b/se

. 
. *** (2C) ESTIMATE COX MODEL SPECIFICATION OF COMPETING RISKS
. 
. stset spell, fail(censor1=1)

     failure event:  censor1 == 1
obs. time interval:  (0, spell]
 exit on or before:  failure

------------------------------------------------------------------------------
     3343  total obs.
        0  exclusions
------------------------------------------------------------------------------
     3343  obs. remaining, representing
     1073  failures in single record/single failure data
    20887  total analysis time at risk, at risk from t =         0
                             earliest observed entry t =         0
                                  last observed exit t =        28

. stcox $xlist, nolog nohr robust basesurv(survrisk1) basechazard(chrisk1)

         failure _d:  censor1 == 1
   analysis time _t:  spell

Cox regression -- Breslow method for ties

No. of subjects       =         3343               Number of obs   =      3343
No. of failures       =         1073
Time at risk          =        20887
                                                   Wald chi2(40)   =    540.98
Log pseudo-likelihood =   -7717.2334               Prob > chi2     =    0.0000

------------------------------------------------------------------------------
             |               Robust
          _t |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          RR |   .5222796   .5711698     0.91   0.361    -.5971926    1.641752
          DR |   -.752507     .72175    -1.04   0.297    -2.167111    .6620971
          UI |  -1.317719   .2372893    -5.55   0.000    -1.782798   -.8526409
        RRUI |   .8822462    .582115     1.52   0.130    -.2586783    2.023171
        DRUI |  -.0951357    .977774    -0.10   0.922    -2.011538    1.821266
     LOGWAGE |   .3352639   .1106483     3.03   0.002     .1183972    .5521306
      tenure |   .0008278   .0061286     0.14   0.893    -.0111841    .0128396
       slack |   -.247863   .0721173    -3.44   0.001    -.3892103   -.1065158
     abolpos |  -.1511638   .0905035    -1.67   0.095    -.3285475    .0262198
     explose |   .1865068   .0615742     3.03   0.002     .0658236      .30719
     stateur |  -.0590475    .022085    -2.67   0.008    -.1023334   -.0157616
    houshead |   .3601866   .0794827     4.53   0.000     .2044035    .5159698
     married |    .358819   .0746355     4.81   0.000     .2125362    .5051019
      female |   .1002758   .0813277     1.23   0.218    -.0591236    .2596753
       child |  -.0396054   .0755365    -0.52   0.600    -.1876542    .1084435
      ychild |  -.1276638   .0967856    -1.32   0.187    -.3173602    .0620325
    nonwhite |  -.6394475   .1151332    -5.55   0.000    -.8651043   -.4137906
         age |  -.0204623   .0037593    -5.44   0.000    -.0278305   -.0130942
     schlt12 |  -.1220585   .0920073    -1.33   0.185    -.3023895    .0582726
     schgt12 |   .1104817   .0783542     1.41   0.159    -.0430897    .2640531
        smsa |   .1864841   .0766075     2.43   0.015     .0363361    .3366321
    bluecoll |  -.2108023    .080867    -2.61   0.009    -.3692986    -.052306
      mining |  -.1238251   .1906352    -0.65   0.516    -.4974632     .249813
      constr |   -.054455   .1029488    -0.53   0.597     -.256231    .1473209
      transp |  -.1551657   .1466515    -1.06   0.290    -.4425973    .1322659
       trade |  -.0383252   .0968106    -0.40   0.692    -.2280706    .1514201
        fire |   .1097585   .1300779     0.84   0.399    -.1451895    .3647065
    services |   .1666262   .0939507     1.77   0.076    -.0175138    .3507662
    pubadmin |   .1022002   .2829817     0.36   0.718    -.4524336    .6568341
      year85 |    .204162    .084908     2.40   0.016     .0377454    .3705786
      year87 |   .3384229   .0899115     3.76   0.000     .1621997    .5146462
      year89 |   .4486559    .104937     4.28   0.000     .2429832    .6543286
      midatl |   .0342238    .140515     0.24   0.808    -.2411805    .3096282
       encen |   .0174597   .1438862     0.12   0.903    -.2645521    .2994716
       wncen |   .1650967   .1532559     1.08   0.281    -.1352795    .4654728
    southatl |   .2518023   .1127138     2.23   0.025     .0308874    .4727172
       escen |   .3450422   .1839818     1.88   0.061    -.0155554    .7056398
       wscen |   .3316752   .1359801     2.44   0.015     .0651591    .5981914
    mountain |    .009484   .1468626     0.06   0.949    -.2783613    .2973293
     pacific |   .0720292   .2263339     0.32   0.750    -.3715771    .5156355
------------------------------------------------------------------------------

. estimates store bcoxrisk1

. 
. stset spell, fail(censor2=1)

     failure event:  censor2 == 1
obs. time interval:  (0, spell]
 exit on or before:  failure

------------------------------------------------------------------------------
     3343  total obs.
        0  exclusions
------------------------------------------------------------------------------
     3343  obs. remaining, representing
      339  failures in single record/single failure data
    20887  total analysis time at risk, at risk from t =         0
                             earliest observed entry t =         0
                                  last observed exit t =        28

. stcox $xlist, nolog nohr robust basesurv(survrisk2) basechazard(chrisk2)

         failure _d:  censor2 == 1
   analysis time _t:  spell

Cox regression -- Breslow method for ties

No. of subjects       =         3343               Number of obs   =      3343
No. of failures       =          339
Time at risk          =        20887
                                                   Wald chi2(40)   =    211.82
Log pseudo-likelihood =    -2444.342               Prob > chi2     =    0.0000

------------------------------------------------------------------------------
             |               Robust
          _t |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          RR |  -.0719673   .9513101    -0.08   0.940    -1.936501    1.792566
          DR |    -1.0236   1.193087    -0.86   0.391    -3.362007    1.314807
          UI |   -.906022   .5109396    -1.77   0.076    -1.907445    .0954013
        RRUI |  -.7818457   1.166182    -0.67   0.503     -3.06752    1.503829
        DRUI |   2.031968   1.671862     1.22   0.224    -1.244821    5.308756
     LOGWAGE |  -.2800345   .1736454    -1.61   0.107    -.6203732    .0603043
      tenure |   .0059934   .0122664     0.49   0.625    -.0180483    .0300352
       slack |  -.2476685     .12775    -1.94   0.053     -.498054    .0027169
     abolpos |  -.5434923   .1976775    -2.75   0.006    -.9309331   -.1560516
     explose |   .0334802   .1101886     0.30   0.761    -.1824856    .2494459
     stateur |  -.0923228   .0393339    -2.35   0.019    -.1694157   -.0152299
    houshead |  -.0864111   .1303336    -0.66   0.507    -.3418602    .1690379
     married |   -.065464   .1298376    -0.50   0.614    -.3199409     .189013
      female |   .4386603   .1340263     3.27   0.001     .1759735    .7013471
       child |  -.2049337   .1413612    -1.45   0.147    -.4819966    .0721293
      ychild |   .1556684   .1766059     0.88   0.378    -.1904727    .5018095
    nonwhite |  -.3956483   .1761206    -2.25   0.025    -.7408382   -.0504583
         age |   .0001207   .0062519     0.02   0.985    -.0121327    .0123741
     schlt12 |  -.1723734   .1618354    -1.07   0.287     -.489565    .1448182
     schgt12 |  -.0583556    .142103    -0.41   0.681    -.3368724    .2201611
        smsa |   .1120279   .1334106     0.84   0.401    -.1494521    .3735079
    bluecoll |  -.0021333   .1460376    -0.01   0.988    -.2883617    .2840951
      mining |  -.0132972    .401138    -0.03   0.974    -.7995132    .7729188
      constr |   .1654229   .1852256     0.89   0.372    -.1976127    .5284584
      transp |  -.3818733   .2831048    -1.35   0.177    -.9367485    .1730019
       trade |   .1065755   .1677346     0.64   0.525    -.2221782    .4353293
        fire |   -.345295   .2945472    -1.17   0.241    -.9225969    .2320068
    services |   .1443583   .1664345     0.87   0.386    -.1818474     .470564
    pubadmin |   .7203208   .5238954     1.37   0.169    -.3064953    1.747137
      year85 |  -.0647735   .1460286    -0.44   0.657    -.3509844    .2214373
      year87 |   -.138436   .1574958    -0.88   0.379    -.4471221    .1702502
      year89 |    .100033   .1887671     0.53   0.596    -.2699437    .4700097
      midatl |  -.3838124   .2529706    -1.52   0.129    -.8796257    .1120009
       encen |  -.5058645   .2521219    -2.01   0.045    -1.000014   -.0117146
       wncen |   -.081463   .2512893    -0.32   0.746    -.5739811     .411055
    southatl |  -.2799968   .1891246    -1.48   0.139    -.6506742    .0906805
       escen |   .0372908   .2993588     0.12   0.901    -.5494417    .6240233
       wscen |  -.1157119   .2286912    -0.51   0.613    -.5639385    .3325146
    mountain |    .204597   .2206239     0.93   0.354    -.2278179    .6370119
     pacific |  -.2138749   .3899895    -0.55   0.583    -.9782404    .5504905
------------------------------------------------------------------------------

. estimates store bcoxrisk2

. 
. stset spell, fail(censor3=1)

     failure event:  censor3 == 1
obs. time interval:  (0, spell]
 exit on or before:  failure

------------------------------------------------------------------------------
     3343  total obs.
        0  exclusions
------------------------------------------------------------------------------
     3343  obs. remaining, representing
      574  failures in single record/single failure data
    20887  total analysis time at risk, at risk from t =         0
                             earliest observed entry t =         0
                                  last observed exit t =        28

. stcox $xlist, nolog nohr robust basesurv(survrisk3) basechazard(chrisk3)

         failure _d:  censor3 == 1
   analysis time _t:  spell

Cox regression -- Breslow method for ties

No. of subjects       =         3343               Number of obs   =      3343
No. of failures       =          574
Time at risk          =        20887
                                                   Wald chi2(40)   =    357.81
Log pseudo-likelihood =   -4094.2361               Prob > chi2     =    0.0000

------------------------------------------------------------------------------
             |               Robust
          _t |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          RR |  -.4692082   .7157644    -0.66   0.512    -1.872081    .9336643
          DR |   .8759221   .8786992     1.00   0.319    -.8462967    2.598141
          UI |  -.9051384   .4449384    -2.03   0.042    -1.777202   -.0330753
        RRUI |  -.5392752   1.002388    -0.54   0.591    -2.503919    1.425369
        DRUI |   2.293752   1.274021     1.80   0.072    -.2032836    4.790787
     LOGWAGE |  -.0140883   .1415912    -0.10   0.921     -.291602    .2634253
      tenure |  -.0465013   .0118142    -3.94   0.000    -.0696567   -.0233458
       slack |  -.4587556   .0952092    -4.82   0.000    -.6453621   -.2721491
     abolpos |  -.2743895    .136703    -2.01   0.045    -.5423223   -.0064566
     explose |   .0199625   .0843281     0.24   0.813    -.1453176    .1852426
     stateur |  -.1013309   .0311307    -3.26   0.001    -.1623459   -.0403159
    houshead |   .5154239   .1031203     5.00   0.000     .3133117     .717536
     married |   .0280002   .1037338     0.27   0.787    -.1753143    .2313148
      female |   .2477194   .1071841     2.31   0.021     .0376425    .4577962
       child |  -.1477253   .1086376    -1.36   0.174    -.3606511    .0652005
      ychild |  -.0702224   .1341067    -0.52   0.601    -.3330667    .1926219
    nonwhite |  -.4472066   .1401892    -3.19   0.001    -.7219723   -.1724409
         age |  -.0227849   .0053188    -4.28   0.000    -.0332096   -.0123602
     schlt12 |  -.1050265   .1191449    -0.88   0.378    -.3385462    .1284931
     schgt12 |   .0912594   .1057371     0.86   0.388    -.1159815    .2985004
        smsa |   .0078536   .0994133     0.08   0.937    -.1869928       .2027
    bluecoll |   .2916892   .1085873     2.69   0.007     .0788619    .5045165
      mining |   .2392902   .2514416     0.95   0.341    -.2535263    .7321067
      constr |   .0659352   .1393882     0.47   0.636    -.2072606     .339131
      transp |  -.0724276   .1845329    -0.39   0.695    -.4341054    .2892502
       trade |   .0824395   .1260009     0.65   0.513    -.1645178    .3293967
        fire |  -.3901171   .2648329    -1.47   0.141      -.90918    .1289458
    services |   .0007351   .1296195     0.01   0.995    -.2533144    .2547847
    pubadmin |  -1.749927   1.038715    -1.68   0.092    -3.785771    .2859182
      year85 |   .2810465   .1124259     2.50   0.012     .0606957    .5013973
      year87 |   .4139684    .117016     3.54   0.000     .1846212    .6433155
      year89 |  -.1485614   .1590621    -0.93   0.350    -.4603173    .1631946
      midatl |  -.5271828   .2165005    -2.44   0.015    -.9515159   -.1028497
       encen |   -.063171   .1962513    -0.32   0.748    -.4478166    .3214745
       wncen |    .134275   .2051501     0.65   0.513    -.2678118    .5363617
    southatl |   .1522905   .1610446     0.95   0.344    -.1633512    .4679321
       escen |  -.5030762   .3118938    -1.61   0.107    -1.114377    .1082245
       wscen |   .0116807   .1858946     0.06   0.950     -.352666    .3760273
    mountain |   .2043736   .1827277     1.12   0.263    -.1537662    .5625134
     pacific |   .4327009   .2661013     1.63   0.104     -.088848    .9542498
------------------------------------------------------------------------------

. estimates store bcoxrisk3

. 
. * Table 19.3 (page 659) last three columns
. * NOTE: The results from this program differ a little from those 
. *       given in text.  Need to resolve this.
. estimates table bcoxrisk1 bcoxrisk2 bcoxrisk3, b(%10.3f) se(%10.3f) stats(N ll) /*
>  */ keep(RR DR UI RRUI DRUI LOGWAGE tenure)

-----------------------------------------------------
    Variable | bcoxrisk1    bcoxrisk2    bcoxrisk3   
-------------+---------------------------------------
          RR |      0.522       -0.072       -0.469  
             |      0.571        0.951        0.716  
          DR |     -0.753       -1.024        0.876  
             |      0.722        1.193        0.879  
          UI |     -1.318       -0.906       -0.905  
             |      0.237        0.511        0.445  
        RRUI |      0.882       -0.782       -0.539  
             |      0.582        1.166        1.002  
        DRUI |     -0.095        2.032        2.294  
             |      0.978        1.672        1.274  
     LOGWAGE |      0.335       -0.280       -0.014  
             |      0.111        0.174        0.142  
      tenure |      0.001        0.006       -0.047  
             |      0.006        0.012        0.012  
-------------+---------------------------------------
           N |   3343.000     3343.000     3343.000  
          ll |  -7717.233    -2444.342    -4094.236  
-----------------------------------------------------
                                         legend: b/se

. 
. *** (2D) GRAPHS FOR COX COMPETING RISKS MODEL
. 
. * Figure 19.1 (page 661) - Plot the three baseline survival functions
. sort _t

. graph twoway (scatter survrisk1 _t, c(J) msymbol(i) msize(small) clstyle(p1)) /*
>   */ (scatter survrisk2 _t, c(J) msymbol(i) msize(small) clstyle(p2)) /*
>   */ (scatter survrisk3 _t, c(J) msymbol(i) msize(small) clstyle(p3)), /*
>   */ scale (1.2) plotregion(style(none)) /*
>   */ title("Baseline Survival Functions") /*
>   */ xtitle("Unemployment Duration in 2-week intervals", size(medlarge)) xscale(titlegap(*5)) /* 
>   */ ytitle("Baseline Survival Probability", size(medlarge)) yscale(titlegap(*5)) /*
>   */ legend(pos(3) ring(0) col(1)) legend(size(small)) /*
>   */ legend( label(1 "Risk 1 (full-time job)") label(2 "Risk 2 (part-time job)") label(3 "Risk 3 (
> unknown job)"))

. graph export combined_bsf.wmf, replace
(file c:\Imbook\bwebpage\Section4\combined_bsf.wmf written in Windows Metafile format)

. 
. * Figure 19.2 (page 659) - Plot the three baseline cumulative hazards
. sort _t

. graph twoway (scatter chrisk1 _t, c(J) msymbol(i) msize(small) clstyle(p1)) /*
>   */ (scatter chrisk2 _t, c(J) msymbol(i) msize(small) clstyle(p2)) /*
>   */ (scatter chrisk3 _t, c(J) msymbol(i) msize(small) clstyle(p3)), /*
>   */ scale (1.2) plotregion(style(none)) /*
>   */ title("Baseline Cumulative Hazard Functions") /*
>   */ xtitle("Unemployment Duration in 2-week intervals", size(medlarge)) xscale(titlegap(*5)) /* 
>   */ ytitle("Baseline Cumulative Hazard", size(medlarge)) yscale(titlegap(*5)) /*
>   */ legend(pos(11) ring(0) col(1)) legend(size(small)) /*
>   */ legend( label(1 "Risk 1 (full-time job)") label(2 "Risk 2 (part-time job)") label(3 "Risk 3 (
> unknown job)"))

. graph export combined_cbh.wmf, replace
(file c:\Imbook\bwebpage\Section4\combined_cbh.wmf written in Windows Metafile format)

. 
. ********** CLOSE OUTPUT **********
. log close
       log:  c:\Imbook\bwebpage\Section4\mma19p1comprisks.txt
  log type:  text
 closed on:  19 May 2005, 17:53:08
----------------------------------------------------------------------------------------------------
