-------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  c:\acdbookrevision\stata_final_programs_2013\racd09.txt
  log type:  text
 opened on:  20 Jan 2013, 17:53:00

. 
. ********** OVERVIEW OF racd09.do **********
. 
. * STATA Program 
. * copyright C 2013 by A. Colin Cameron and Pravin K. Trivedi 
. * used for "Regression Analyis of Count Data" SECOND EDITION
. * by A. Colin Cameron and Pravin K. Trivedi (2013)
. * Cambridge University Press
. 
. * This STATA program analyzes patent data for chapter 9
. *   9.4 FIXED EFFECTS and POOLED (PA / GEE) ESTIMATORS
. *   9.5 RANDOM EFFECTS ESTIMATORS
. *   9.8 DYNAMIC MODELS WITH RANDOM and FIXED EFFECTS
. * It provides much more detail than is in the book
. 
. * It takes a long time due to bootstraps to get panel robust se's
. * In a couple of places bootstrap and jackknifes are commented out
. * to speed up the program.
. * In those cases the output is included as a comment.
. 
. * To run you need file
. *   racd09data.dta
. * in your directory
. 
. ********** SETUP **********
. 
. set more off

. version 12

. clear all

. * set linesize 82
. set scheme s1mono  /* Graphics scheme */

. * set maxvar 100 width 1000
. 
. ********** DATA DESCRIPTION
. 
. *  The original data is from 
. *  Bronwyn Hall, Zvi Griliches, and Jerry Hausman (1986), 
. * "Patents and R&D: Is There a Lag?", 
. *  International Economic Review, 27, 265-283.
. * See this article for more detailed discussion 
. * Also see racd09makedata.do for further details 
. 
. ********** 9.4 PATENTS: READ DATA AND SUMMARIZE 
. 
. * This program gets clustered standard errors by bootstrap or jackknife
. * when these are not provided by XT commands
. * To speed up the program 
. * 1. Drop vce(jackkife) where it appears (this has been done here)
. * 2. Reduce BREPS from 400
. 
. global BREPS 400

. 
. use racd09data.dta, clear

. 
. *** TABLE 9.1: FREQUENCY DISTRIBUTION and SUMMARY STATISTICS for patents
. 
. generate PATRANGE =  PAT

. recode PATRANGE (0=0) (1/5=1) (6/10=6) (11/20=11) (21/50=21) (51/100=51) (101/200=101) (201/515=201)
(PATRANGE: 1124 changes made)

. tabulate PATRANGE

   PATRANGE |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        337       19.48       19.48
          1 |        565       32.66       52.14
          6 |        139        8.03       60.17
         11 |        140        8.09       68.27
         21 |        223       12.89       81.16
         51 |        146        8.44       89.60
        101 |        107        6.18       95.78
        201 |         73        4.22      100.00
------------+-----------------------------------
      Total |      1,730      100.00

. summarize PAT, detail 

       Number of (successful) patents applied for this
                            year
-------------------------------------------------------------
      Percentiles      Smallest
 1%            0              0
 5%            0              0
10%            0              0       Obs                1730
25%            1              0       Sum of Wgt.        1730

50%            5                      Mean           34.77168
                        Largest       Std. Dev.      70.87538
75%           33            487
90%          105            495       Variance       5023.319
95%          182            508       Skewness       3.455604
99%          378            515       Kurtosis       17.11843

. 
. * Variable descriptions and summary statistics
. describe

Contains data from racd09data.dta
  obs:         1,730                          
 vars:            24                          7 Jun 2011 11:01
 size:       166,080                          
-------------------------------------------------------------------------------------------------------------------------------
              storage  display     value
variable name   type   format      label      variable label
-------------------------------------------------------------------------------------------------------------------------------
OBSNO           float  %9.0g                  
YEAR            float  %9.0g                  Year
CUSIP           float  %9.0g                  Compustat identifier for the firm
ARDSIC          float  %9.0g                  Two-digit code for the applied R&D industrial classification
SCISECT         float  %9.0g                  Equals 1 if firm in the scientific sector
LOGK            float  %9.0g                  Logarithm of the book value of capital in 1972
SUMPAT          float  %9.0g                  Sum of patents applied for between 1972-1979
PAT             float  %9.0g                  Number of (successful) patents applied for this year
PAT1            float  %9.0g                  Number of (successful) patents applied for lagged one year
PAT2            float  %9.0g                  Number of (successful) patents applied for lagged two years
PAT3            float  %9.0g                  Number of (successful) patents applied for lagged three years
PAT4            float  %9.0g                  Number of (successful) patents applied for lagged four years
LOGR            float  %9.0g                  Logarithm of R&D spending this year (in 1972$)
LOGR1           float  %9.0g                  Logarithm of R&D spending lagged one year (in 1972$)
LOGR2           float  %9.0g                  Logarithm of R&D spending lagged two years (in 1972$)
LOGR3           float  %9.0g                  Logarithm of R&D spending lagged three years (in 1972$)
LOGR4           float  %9.0g                  Logarithm of R&D spending lagged four years (in 1972$)
LOGR5           float  %9.0g                  Logarithm of R&D spending lagged five years (in 1972$)
id              float  %9.0g                  id
dyear2          float  %9.0g                  = 1 if YEAR = 2
dyear3          float  %9.0g                  = 1 if YEAR = 3
dyear4          float  %9.0g                  = 1 if YEAR = 4
dyear5          float  %9.0g                  = 1 if YEAR = 5
PATRANGE        float  %9.0g                  
-------------------------------------------------------------------------------------------------------------------------------
Sorted by:  id  YEAR
     Note:  dataset has changed since last saved

. summarize

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       OBSNO |      1730       173.5    99.91006          1        346
        YEAR |      1730           3    1.414622          1          5
       CUSIP |      1730    531201.2    281748.4        800     989399
      ARDSIC |      1730   -19.18497    169.1684       -999         21
     SCISECT |      1730    .4248555     .494464          0          1
-------------+--------------------------------------------------------
        LOGK |      1730    3.921063    2.093117   -1.76965    9.66626
      SUMPAT |      1730    284.7312    570.4526          0       3806
         PAT |      1730    34.77168    70.87538          0        515
        PAT1 |      1730    35.87341    72.76243          0        528
        PAT2 |      1730    36.70289    75.12335          0        595
-------------+--------------------------------------------------------
        PAT3 |      1730     36.7185    75.52676          0        595
        PAT4 |      1730     37.1711    76.53968          0        595
        LOGR |      1730    1.256163    2.006314   -3.84868    7.03432
       LOGR1 |      1730    1.233574    1.984091   -3.84868    7.06524
       LOGR2 |      1730    1.218499    1.966808   -3.84868    7.06524
-------------+--------------------------------------------------------
       LOGR3 |      1730    1.205683    1.951968   -3.84868    7.06524
       LOGR4 |      1730    1.196941    1.942034   -3.67395    7.06524
       LOGR5 |      1730    1.203451    1.934293   -3.67395    7.06524
          id |      1730       173.5    99.91006          1        346
      dyear2 |      1730          .2    .4001157          0          1
-------------+--------------------------------------------------------
      dyear3 |      1730          .2    .4001157          0          1
      dyear4 |      1730          .2    .4001157          0          1
      dyear5 |      1730          .2    .4001157          0          1
    PATRANGE |      1730    23.43815    45.57332          0        201

. 
. * Panel view
. tsset
       panel variable:  id (strongly balanced)
        time variable:  YEAR, 1 to 5
                delta:  1 unit

. xtdescribe

      id:  1, 2, ..., 346                                    n =        346
    YEAR:  1, 2, ..., 5                                      T =          5
           Delta(YEAR) = 1 unit
           Span(YEAR)  = 5 periods
           (id*YEAR uniquely identifies each observation)

Distribution of T_i:   min      5%     25%       50%       75%     95%     max
                         5       5       5         5         5       5       5

     Freq.  Percent    Cum. |  Pattern
 ---------------------------+---------
      346    100.00  100.00 |  11111
 ---------------------------+---------
      346    100.00         |  XXXXX

. xtsum PAT LOGR LOGR5 dyear2 dyear5 LOGK SCISECT 

Variable         |      Mean   Std. Dev.       Min        Max |    Observations
-----------------+--------------------------------------------+----------------
PAT      overall |  34.77168   70.87538          0        515 |     N =    1730
         between |             69.83142          0        473 |     n =     346
         within  |             12.57671  -157.6283   200.3717 |     T =       5
                 |                                            |
LOGR     overall |  1.256163   2.006314   -3.84868    7.03432 |     N =    1730
         between |             1.996594  -3.415914   6.898732 |     n =     346
         within  |             .2193893   -.041151   2.388007 |     T =       5
                 |                                            |
LOGR5    overall |  1.203451   1.934293   -3.67395    7.06524 |     N =    1730
         between |             1.917687   -2.99075   6.924144 |     n =     346
         within  |             .2692134  -.1899074   4.062701 |     T =       5
                 |                                            |
dyear2   overall |        .2   .4001157          0          1 |     N =    1730
         between |                    0         .2         .2 |     n =     346
         within  |             .4001157          0          1 |     T =       5
                 |                                            |
dyear5   overall |        .2   .4001157          0          1 |     N =    1730
         between |                    0         .2         .2 |     n =     346
         within  |             .4001157          0          1 |     T =       5
                 |                                            |
LOGK     overall |  3.921063   2.093117   -1.76965    9.66626 |     N =    1730
         between |             2.095542   -1.76965    9.66626 |     n =     346
         within  |                    0   3.921063   3.921063 |     T =       5
                 |                                            |
SCISECT  overall |  .4248555    .494464          0          1 |     N =    1730
         between |             .4950369          0          1 |     n =     346
         within  |                    0   .4248555   .4248555 |     T =       5

. 
. * Serial correlation in PAT and LOGR
. forvalues j = 1/4 {
  2.      quietly corr PAT L`j'.PAT
  3.      display "Autocorrelation at lag `j' = " %6.3f r(rho) 
  4.      }
Autocorrelation at lag 1 =  0.979
Autocorrelation at lag 2 =  0.966
Autocorrelation at lag 3 =  0.945
Autocorrelation at lag 4 =  0.946

. forvalues j = 1/4 {
  2.      quietly corr LOGR L`j'.LOGR
  3.      display "Autocorrelation at lag `j' = " %6.3f r(rho) 
  4.      }
Autocorrelation at lag 1 =  0.993
Autocorrelation at lag 2 =  0.987
Autocorrelation at lag 3 =  0.980
Autocorrelation at lag 4 =  0.973

. 
. * First-order autocorrelation differs in different year pairs
. forvalues s = 2/4 {
  2.      quietly corr PAT L1.PAT if YEAR == `s'
  3.      display "Autocorrelation at lag 1 in year `s' = " %6.3f r(rho) 
  4.      }
Autocorrelation at lag 1 in year 2 =  0.991
Autocorrelation at lag 1 in year 3 =  0.985
Autocorrelation at lag 1 in year 4 =  0.970

. forvalues s = 2/4 {
  2.      quietly corr LOGR L1.LOGR if YEAR == `s'
  3.      display "Autocorrelation at lag 1 in year `s' = " %6.3f r(rho) 
  4.      }
Autocorrelation at lag 1 in year 2 =  0.993
Autocorrelation at lag 1 in year 3 =  0.992
Autocorrelation at lag 1 in year 4 =  0.994

. 
. by id: egen PATMEAN = mean(PAT)

. generate PATDEV = PAT - PATMEAN

. sort YEAR

. summarize PATMEAN in 1/346, detail

                           PATMEAN
-------------------------------------------------------------
      Percentiles      Smallest
 1%            0              0
 5%            0              0
10%           .2              0       Obs                 346
25%          1.4              0       Sum of Wgt.         346

50%            5                      Mean           34.77168
                        Largest       Std. Dev.      69.83142
75%           33          329.4
90%        105.8          421.2       Variance       4876.427
95%        181.6          433.4       Skewness       3.329953
99%        329.4            473       Kurtosis       15.79888

. bysort YEAR: sum PAT

-------------------------------------------------------------------------------------------------------------------------------
-> YEAR = 1

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
         PAT |       346    36.87283    75.98788          0        508

-------------------------------------------------------------------------------------------------------------------------------
-> YEAR = 2

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
         PAT |       346    35.84682    73.31613          0        487

-------------------------------------------------------------------------------------------------------------------------------
-> YEAR = 3

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
         PAT |       346    36.23121    72.75146          0        456

-------------------------------------------------------------------------------------------------------------------------------
-> YEAR = 4

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
         PAT |       346    32.80636     65.6505          0        434

-------------------------------------------------------------------------------------------------------------------------------
-> YEAR = 5

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
         PAT |       346    32.10116    66.36197          0        515


. 
. sort id YEAR

. 
. ********** ASIDE: CROSS SECTION MODELS 
. 
. global XLIST LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 LOGK SCISECT dyear2 dyear3 dyear4 dyear5

. * global XLIST LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5 LOGK SCISECT
. global XLISTTIMEVARYING LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5

. 
. * Serial correlation in residuals
. quietly poisson PAT $XLIST

. predict poissrawresid, score

. forvalues j = 1/4 {
  2.      quietly corr poissrawresid L`j'.poissrawresid
  3.      display "Autocorrelation at lag `j' = " %6.3f r(rho) 
  4.      }
Autocorrelation at lag 1 =  0.946
Autocorrelation at lag 2 =  0.902
Autocorrelation at lag 3 =  0.851
Autocorrelation at lag 4 =  0.847

. forvalues s = 2/4 {
  2.      quietly corr poissrawresid L1.poissrawresid if YEAR == `s'
  3.      display "Autocorrelation at lag 1 in year `s' = " %6.3f r(rho) 
  4.      }
Autocorrelation at lag 1 in year 2 =  0.973
Autocorrelation at lag 1 in year 3 =  0.961
Autocorrelation at lag 1 in year 4 =  0.927

. 
. * Serial correlation in residuals
. quietly poisson PAT $XLIST i.id

. predict poissrawresid2, score

. forvalues j = 1/4 {
  2.      quietly corr poissrawresid2 L`j'.poissrawresid2
  3.      display "Autocorrelation at lag `j' = " %6.3f r(rho) 
  4.      }
Autocorrelation at lag 1 =  0.234
Autocorrelation at lag 2 = -0.374
Autocorrelation at lag 3 = -0.741
Autocorrelation at lag 4 = -0.554

. forvalues s = 2/4 {
  2.      quietly corr poissrawresid2 L1.poissrawresid2 if YEAR == `s'
  3.      display "Autocorrelation at lag 1 in year `s' = " %6.3f r(rho) 
  4.      }
Autocorrelation at lag 1 in year 2 =  0.640
Autocorrelation at lag 1 in year 3 = -0.018
Autocorrelation at lag 1 in year 4 = -0.076

. 
. * Poisson Cross-section
. quietly poisson PAT $XLIST

. estimates store PCSdef

. quietly poisson PAT $XLIST, vce(robust)

. estimates store PCSrob

. * Following standard errors are preferred
. quietly poisson PAT $XLIST, vce(cluster id)

. estimates store PCSclu

. display "Table 9.2: first column Sum ln R"
Table 9.2: first column Sum ln R

. lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5

 ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 + [PAT]LOGR3 + [PAT]LOGR4 + [PAT]LOGR5 = 0

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .4856263   .0752866     6.45   0.000     .3380673    .6331854
------------------------------------------------------------------------------

. 
. * Negative binomial NB2 Cross-section
. quietly nbreg PAT $XLIST

. estimates store NBCSdef

. quietly nbreg PAT $XLIST, vce(robust)

. estimates store NBCSrob

. * Following standard errors are preferred
. quietly nbreg PAT $XLIST, vce(cluster id)

. lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5

 ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 + [PAT]LOGR3 + [PAT]LOGR4 + [PAT]LOGR5 = 0

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .8100443   .0636399    12.73   0.000     .6853124    .9347762
------------------------------------------------------------------------------

. estimates store NBCSclu

. 
. estimates table PCSdef PCSrob PCSclu NBCSdef NBCSrob NBCSclu, b(%7.4f) se(%7.3f) stats(N ll) 

--------------------------------------------------------------------------
    Variable | PCSdef    PCSrob    PCSclu    NBCSdef   NBCSrob   NBCSclu  
-------------+------------------------------------------------------------
PAT          |
        LOGR |  0.1345    0.1345    0.1345    0.4311    0.4311    0.4311  
             |   0.031     0.180     0.183     0.112     0.141     0.133  
       LOGR1 | -0.0529   -0.0529   -0.0529   -0.1171   -0.1171   -0.1171  
             |   0.043     0.242     0.106     0.156     0.186     0.141  
       LOGR2 |  0.0082    0.0082    0.0082    0.1065    0.1065    0.1065  
             |   0.040     0.232     0.093     0.150     0.168     0.121  
       LOGR3 |  0.0661    0.0661    0.0661    0.0764    0.0764    0.0764  
             |   0.037     0.221     0.114     0.137     0.155     0.103  
       LOGR4 |  0.0902    0.0902    0.0902    0.1938    0.1938    0.1938  
             |   0.033     0.198     0.093     0.125     0.128     0.088  
       LOGR5 |  0.2395    0.2395    0.2395    0.1194    0.1194    0.1194  
             |   0.022     0.132     0.123     0.085     0.090     0.086  
        LOGK |  0.2529    0.2529    0.2529    0.1013    0.1013    0.1013  
             |   0.004     0.028     0.059     0.024     0.027     0.054  
     SCISECT |  0.4543    0.4543    0.4543   -0.0046   -0.0046   -0.0046  
             |   0.009     0.077     0.167     0.056     0.059     0.119  
      dyear2 | -0.0435   -0.0435   -0.0435   -0.0558   -0.0558   -0.0558  
             |   0.013     0.096     0.018     0.077     0.076     0.035  
      dyear3 | -0.0524   -0.0524   -0.0524   -0.0609   -0.0609   -0.0609  
             |   0.013     0.097     0.030     0.077     0.080     0.043  
      dyear4 | -0.1702   -0.1702   -0.1702   -0.1220   -0.1220   -0.1220  
             |   0.014     0.094     0.046     0.077     0.085     0.047  
      dyear5 | -0.2019   -0.2019   -0.2019   -0.2267   -0.2267   -0.2267  
             |   0.014     0.089     0.046     0.077     0.085     0.049  
       _cons |  0.8099    0.8099    0.8099    0.9088    0.9088    0.9088  
             |   0.021     0.130     0.242     0.097     0.105     0.182  
-------------+------------------------------------------------------------
lnalpha      |
       _cons |                               -0.2660   -0.2660   -0.2660  
             |                                 0.044     0.048     0.089  
-------------+------------------------------------------------------------
Statistics   |                                                            
           N |    1730      1730      1730      1730      1730      1730  
          ll | -1.8e+04   -1.8e+04   -1.8e+04   -5.8e+03   -5.8e+03   -5.8e+03  
--------------------------------------------------------------------------
                                                              legend: b/se

. 
. ********* 9.4 POPULATION AVERAGED MODELS
. 
. * Poisson GEE exchangeable
. quietly xtgee PAT $XLIST, family(poisson) corr(exch)

. estimates store PPAEXdef

. * Following standard errors are preferred
. xtgee PAT $XLIST, family(poisson) corr(exch) vce(robust)

Iteration 1: tolerance = .1414367
Iteration 2: tolerance = .02055835
Iteration 3: tolerance = .00182509
Iteration 4: tolerance = .00017476
Iteration 5: tolerance = .00001718
Iteration 6: tolerance = 1.732e-06
Iteration 7: tolerance = 1.776e-07

GEE population-averaged model                   Number of obs      =      1730
Group variable:                         id      Number of groups   =       346
Link:                                  log      Obs per group: min =         5
Family:                            Poisson                     avg =       5.0
Correlation:                  exchangeable                     max =         5
                                                Wald chi2(12)      =    671.74
Scale parameter:                         1      Prob > chi2        =    0.0000

                                     (Std. Err. adjusted for clustering on id)
------------------------------------------------------------------------------
             |               Robust
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        LOGR |   .3155815    .061931     5.10   0.000      .194199    .4369639
       LOGR1 |  -.0522286      .0602    -0.87   0.386    -.1702185    .0657612
       LOGR2 |    .104817   .0535308     1.96   0.050    -.0001014    .2097354
       LOGR3 |   .0196527   .0674715     0.29   0.771    -.1125891    .1518945
       LOGR4 |   .0229611   .0535738     0.43   0.668    -.0820415    .1279638
       LOGR5 |   .0488891   .0551695     0.89   0.376    -.0592411    .1570192
        LOGK |   .2698966   .0566612     4.76   0.000     .1588426    .3809505
     SCISECT |   .4402067   .1751261     2.51   0.012     .0969658    .7834476
      dyear2 |  -.0455811   .0170808    -2.67   0.008    -.0790589   -.0121034
      dyear3 |  -.0462482   .0259597    -1.78   0.075    -.0971283    .0046319
      dyear4 |  -.1685656   .0408254    -4.13   0.000     -.248582   -.0885492
      dyear5 |  -.2135843   .0413192    -5.17   0.000    -.2945685   -.1326002
       _cons |   .7774219   .2448108     3.18   0.001     .2976016    1.257242
------------------------------------------------------------------------------

. estimates store PPAEXrob

. display "Table 9.2: second column Sum ln R"
Table 9.2: second column Sum ln R

. lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5

 ( 1)  LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5 = 0

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .4596728   .0698585     6.58   0.000     .3227527    .5965929
------------------------------------------------------------------------------

. * Poisson GEE AR(1) errors
. quietly xtgee PAT $XLIST, family(poisson) corr(ar1) vce(robust)

. estimates store PPAARrob

. 
. * Negative binomial
. * Here we need to give the value of alpha - use the cross-section nbreg estimate
. * Furthermore needs to be done manually (can't use alpha where scalar alpha = e(alpha))
. quietly nbreg PAT $XLIST

. scalar alpha = e(alpha)

. display "The correct alpha to use is: " alpha
The correct alpha to use is: .76642446

. * NB2 GEE exchangeable errors errors
. xtgee PAT $XLIST, family(nbinomial .7785956) corr(exch)

Iteration 1: tolerance = .08658775
Iteration 2: tolerance = .01420478
Iteration 3: tolerance = .00226872
Iteration 4: tolerance = .00040058
Iteration 5: tolerance = .00008206
Iteration 6: tolerance = .00001543
Iteration 7: tolerance = 2.957e-06
Iteration 8: tolerance = 5.594e-07

GEE population-averaged model                   Number of obs      =      1730
Group variable:                         id      Number of groups   =       346
Link:                                  log      Obs per group: min =         5
Family:        negative binomial(k=1.2844)                     avg =       5.0
Correlation:                  exchangeable                     max =         5
                                                Wald chi2(12)      =   1275.79
Scale parameter:                         1      Prob > chi2        =    0.0000

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        LOGR |   .5204098   .0791055     6.58   0.000     .3653659    .6754537
       LOGR1 |  -.0848338   .0933313    -0.91   0.363    -.2677599    .0980922
       LOGR2 |   .1249174    .086829     1.44   0.150    -.0452643    .2950991
       LOGR3 |   .0533976   .0805725     0.66   0.508    -.1045216    .2113169
       LOGR4 |   .0914135   .0737452     1.24   0.215    -.0531243    .2359514
       LOGR5 |   .0236248    .057445     0.41   0.681    -.0889652    .1362149
        LOGK |    .163459   .0409921     3.99   0.000     .0831159     .243802
     SCISECT |   .0687045   .1045165     0.66   0.511    -.1361441     .273553
      dyear2 |  -.0535706   .0445095    -1.20   0.229    -.1408075    .0336664
      dyear3 |  -.0575273   .0449518    -1.28   0.201    -.1456311    .0305765
      dyear4 |   -.123724   .0450283    -2.75   0.006    -.2119779   -.0354701
      dyear5 |  -.2392881   .0453723    -5.27   0.000    -.3282162   -.1503599
       _cons |   .7333156   .1558079     4.71   0.000     .4279378    1.038693
------------------------------------------------------------------------------

. estimates store NBPAEXdef

. * Following standard errors are preferred
. xtgee PAT $XLIST, family(nbinomial .7785956) corr(exch) vce(robust)

Iteration 1: tolerance = .08658775
Iteration 2: tolerance = .01420478
Iteration 3: tolerance = .00226872
Iteration 4: tolerance = .00040058
Iteration 5: tolerance = .00008206
Iteration 6: tolerance = .00001543
Iteration 7: tolerance = 2.957e-06
Iteration 8: tolerance = 5.594e-07

GEE population-averaged model                   Number of obs      =      1730
Group variable:                         id      Number of groups   =       346
Link:                                  log      Obs per group: min =         5
Family:        negative binomial(k=1.2844)                     avg =       5.0
Correlation:                  exchangeable                     max =         5
                                                Wald chi2(12)      =   1707.70
Scale parameter:                         1      Prob > chi2        =    0.0000

                                     (Std. Err. adjusted for clustering on id)
------------------------------------------------------------------------------
             |             Semirobust
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        LOGR |   .5204098    .107983     4.82   0.000      .308767    .7320526
       LOGR1 |  -.0848338    .112758    -0.75   0.452    -.3058354    .1361678
       LOGR2 |   .1249174   .0852358     1.47   0.143    -.0421418    .2919765
       LOGR3 |   .0533976   .0989001     0.54   0.589     -.140443    .2472383
       LOGR4 |   .0914135   .0826048     1.11   0.268    -.0704888    .2533159
       LOGR5 |   .0236248   .0614235     0.38   0.701     -.096763    .1440127
        LOGK |    .163459   .0466632     3.50   0.000     .0720007    .2549172
     SCISECT |   .0687045   .1137579     0.60   0.546    -.1542568    .2916658
      dyear2 |  -.0535706   .0337001    -1.59   0.112    -.1196216    .0124805
      dyear3 |  -.0575273   .0403097    -1.43   0.154    -.1365329    .0214782
      dyear4 |   -.123724   .0460129    -2.69   0.007    -.2139076   -.0335404
      dyear5 |  -.2392881   .0486633    -4.92   0.000    -.3346663   -.1439098
       _cons |   .7333156   .1686302     4.35   0.000     .4028064    1.063825
------------------------------------------------------------------------------

. estimates store NBPAEXrob

. * NB2 GEE AR(1) errors
. xtgee PAT $XLIST, family(nbinomial .7785956) corr(ar1) vce(robust)

Iteration 1: tolerance = .09358647
Iteration 2: tolerance = .00925672
Iteration 3: tolerance = .00101627
Iteration 4: tolerance = .00020977
Iteration 5: tolerance = .00002707
Iteration 6: tolerance = 6.827e-06
Iteration 7: tolerance = 1.108e-06
Iteration 8: tolerance = 2.525e-07

GEE population-averaged model                   Number of obs      =      1730
Group and time vars:               id YEAR      Number of groups   =       346
Link:                                  log      Obs per group: min =         5
Family:        negative binomial(k=1.2844)                     avg =       5.0
Correlation:                         AR(1)                     max =         5
                                                Wald chi2(12)      =   1635.21
Scale parameter:                         1      Prob > chi2        =    0.0000

                                     (Std. Err. adjusted for clustering on id)
------------------------------------------------------------------------------
             |             Semirobust
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        LOGR |   .4628448   .1057626     4.38   0.000     .2555538    .6701357
       LOGR1 |   -.057346   .1045565    -0.55   0.583    -.2622729    .1475809
       LOGR2 |   .1465882   .0958547     1.53   0.126    -.0412836      .33446
       LOGR3 |   .0759155   .1030232     0.74   0.461    -.1260062    .2778373
       LOGR4 |   .1447976   .0742072     1.95   0.051    -.0006458     .290241
       LOGR5 |    .014246   .0643692     0.22   0.825    -.1119153    .1404074
        LOGK |   .1191441   .0487287     2.45   0.014     .0236376    .2146507
     SCISECT |   .0114246   .1151492     0.10   0.921    -.2142637     .237113
      dyear2 |  -.0534989   .0342032    -1.56   0.118    -.1205358    .0135381
      dyear3 |  -.0546555   .0423031    -1.29   0.196     -.137568    .0282571
      dyear4 |  -.1148204    .047687    -2.41   0.016    -.2082851   -.0213556
      dyear5 |  -.2301842   .0516966    -4.45   0.000    -.3315076   -.1288607
       _cons |   .8552731   .1749549     4.89   0.000     .5123678    1.198178
------------------------------------------------------------------------------

. estimates store NBPAARrob

. 
. estimates table PPAEXdef PPAEXrob PPAARrob NBPAEXdef NBPAEXrob NBPAARrob, b(%7.4f) se(%7.3f) stats(N ll)

--------------------------------------------------------------------------
    Variable | PPAEX~f   PPAEX~b   PPAAR~b   NBPAE~f   NBPAE~b   NBPAA~b  
-------------+------------------------------------------------------------
        LOGR |  0.3156    0.3156    0.2573    0.5204    0.5204    0.4628  
             |   0.014     0.062     0.056     0.079     0.108     0.106  
       LOGR1 | -0.0522   -0.0522   -0.0280   -0.0848   -0.0848   -0.0573  
             |   0.016     0.060     0.058     0.093     0.113     0.105  
       LOGR2 |  0.1048    0.1048    0.1201    0.1249    0.1249    0.1466  
             |   0.014     0.054     0.058     0.087     0.085     0.096  
       LOGR3 |  0.0197    0.0197    0.0459    0.0534    0.0534    0.0759  
             |   0.013     0.067     0.060     0.081     0.099     0.103  
       LOGR4 |  0.0230    0.0230    0.0537    0.0914    0.0914    0.1448  
             |   0.012     0.054     0.050     0.074     0.083     0.074  
       LOGR5 |  0.0489    0.0489    0.0268    0.0236    0.0236    0.0142  
             |   0.010     0.055     0.046     0.057     0.061     0.064  
        LOGK |  0.2699    0.2699    0.2623    0.1635    0.1635    0.1191  
             |   0.008     0.057     0.054     0.041     0.047     0.049  
     SCISECT |  0.4402    0.4402    0.4708    0.0687    0.0687    0.0114  
             |   0.019     0.175     0.170     0.105     0.114     0.115  
      dyear2 | -0.0456   -0.0456   -0.0453   -0.0536   -0.0536   -0.0535  
             |   0.005     0.017     0.017     0.045     0.034     0.034  
      dyear3 | -0.0462   -0.0462   -0.0447   -0.0575   -0.0575   -0.0547  
             |   0.005     0.026     0.026     0.045     0.040     0.042  
      dyear4 | -0.1686   -0.1686   -0.1633   -0.1237   -0.1237   -0.1148  
             |   0.005     0.041     0.042     0.045     0.046     0.048  
      dyear5 | -0.2136   -0.2136   -0.2053   -0.2393   -0.2393   -0.2302  
             |   0.005     0.041     0.041     0.045     0.049     0.052  
       _cons |  0.7774    0.7774    0.7498    0.7333    0.7333    0.8553  
             |   0.039     0.245     0.234     0.156     0.169     0.175  
-------------+------------------------------------------------------------
           N |    1730      1730      1730      1730      1730      1730  
          ll |                                                            
--------------------------------------------------------------------------
                                                              legend: b/se

. 
. ********** 9.4 FIXED EFFECTS MODELS
. 
. * Poisson fixed effects
. quietly xtpoisson PAT $XLIST, fe

. estimates store PFEdef

. * Following standard errors are preferred
. xtpoisson PAT $XLIST, fe vce(robust)
note: 22 groups (110 obs) dropped because of all zero outcomes
note: LOGK dropped because it is constant within group
note: SCISECT dropped because it is constant within group

Iteration 0:   log pseudolikelihood = -3660.2656  
Iteration 1:   log pseudolikelihood = -3536.3518  
Iteration 2:   log pseudolikelihood = -3536.3086  
Iteration 3:   log pseudolikelihood = -3536.3086  

Conditional fixed-effects Poisson regression    Number of obs      =      1620
Group variable: id                              Number of groups   =       324

                                                Obs per group: min =         5
                                                               avg =       5.0
                                                               max =         5

                                                Wald chi2(10)      =     48.17
Log pseudolikelihood  = -3536.3086              Prob > chi2        =    0.0000

                                     (Std. Err. adjusted for clustering on id)
------------------------------------------------------------------------------
             |               Robust
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        LOGR |   .3222105   .0807547     3.99   0.000     .1639341    .4804868
       LOGR1 |  -.0871295   .0712049    -1.22   0.221    -.2266885    .0524295
       LOGR2 |   .0785816   .0620597     1.27   0.205    -.0430532    .2002164
       LOGR3 |     .00106    .078183     0.01   0.989    -.1521758    .1542958
       LOGR4 |  -.0046414    .063583    -0.07   0.942    -.1292617     .119979
       LOGR5 |   .0026068   .0759235     0.03   0.973    -.1462004    .1514141
      dyear2 |  -.0426076   .0167407    -2.55   0.011    -.0754187   -.0097965
      dyear3 |  -.0400462   .0248168    -1.61   0.107    -.0886862    .0085939
      dyear4 |  -.1571185    .035894    -4.38   0.000    -.2274694   -.0867676
      dyear5 |  -.1980306   .0368759    -5.37   0.000    -.2703059   -.1257552
------------------------------------------------------------------------------

. estimates store PFErob

. display "Table 9.2: third column Sum ln R"
Table 9.2: third column Sum ln R

. lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5

 ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 + [PAT]LOGR3 + [PAT]LOGR4 + [PAT]LOGR5 = 0

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |    .312688   .1431872     2.18   0.029     .0320462    .5933298
------------------------------------------------------------------------------

. 
. * Following checks with a jackknife
. * xtpoisson PAT $XLIST, fe vce(jackknife)
. * estimates store PFEjack
. * Dummy variables - gives same estimates and almost same standard errors
. * poisson PAT $XLIST i.id, vce(cluster id)
. * estimates store PFEDVclu
. 
. * Negative binomial fixed effects
. quietly xtnbreg PAT $XLIST, fe

. estimates store NBFEdef

. * Following takes a while - may want to comment out
. * xtnbreg PAT $XLIST, fe vce(jacknife)   // Jackknife as no vce(robust) here
. * estimates store NBFEjack
. display "Table 9.2: fourth column Sum ln R"
Table 9.2: fourth column Sum ln R

. lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5

 ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 + [PAT]LOGR3 + [PAT]LOGR4 + [PAT]LOGR5 = 0

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .1929697   .0756175     2.55   0.011     .0447621    .3411774
------------------------------------------------------------------------------

. * Dummy variables - gives different estimates
. * nbreg PAT $XLIST i.id, vce(cluster id) dispersion(constant)
. * estimates store NBFEDVclu
. 
. estimates table PFEdef PFErob NBFEdef, b(%7.4f) se(%7.3f) stats(N ll) equations(1)

--------------------------------------------
    Variable | PFEdef    PFErob    NBFEdef  
-------------+------------------------------
        LOGR |  0.3222    0.3222    0.2727  
             |   0.046     0.081     0.071  
       LOGR1 | -0.0871   -0.0871   -0.0979  
             |   0.049     0.071     0.077  
       LOGR2 |  0.0786    0.0786    0.0321  
             |   0.045     0.062     0.071  
       LOGR3 |  0.0011    0.0011   -0.0204  
             |   0.041     0.078     0.066  
       LOGR4 | -0.0046   -0.0046    0.0162  
             |   0.038     0.064     0.063  
       LOGR5 |  0.0026    0.0026   -0.0097  
             |   0.032     0.076     0.053  
      dyear2 | -0.0426   -0.0426   -0.0384  
             |   0.013     0.017     0.024  
      dyear3 | -0.0400   -0.0400   -0.0399  
             |   0.013     0.025     0.025  
      dyear4 | -0.1571   -0.1571   -0.1443  
             |   0.014     0.036     0.026  
      dyear5 | -0.1980   -0.1980   -0.1958  
             |   0.015     0.037     0.027  
        LOGK |                      0.2071  
             |                       0.078  
     SCISECT |                      0.0176  
             |                       0.198  
       _cons |                      1.6614  
             |                       0.344  
-------------+------------------------------
           N |    1620      1620      1620  
          ll | -3.5e+03   -3.5e+03   -3.2e+03  
--------------------------------------------
                                legend: b/se

. 
. /*  . xtnbreg PAT $XLIST, fe vce(jacknife)   // Jackknife as no vce(robust) here
> (running xtnbreg on estimation sample)
> 
> Jackknife replications (324)
> ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
> ..................................................    50
> ..................................................   100
> ..................................................   150
> ..................................................   200
> ..................................................   250
> ..................................................   300
> ........................
> Conditional FE negative binomial regression     Number of obs      =      1620
> Group variable: id                              Number of groups   =       324
> 
>                                                 Obs per group: min =         5
>                                                                avg =       5.0
>                                                                max =         5
> 
>                                                 F(    12,     323) =      6.96
> Log likelihood  = -3203.0644                    Prob > F           =    0.0000
> 
>                                     (Replications based on 324 clusters in id)
> ------------------------------------------------------------------------------
>              |              Jackknife
>          PAT |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>         LOGR |    .272679   .0801407     3.40   0.001     .1150154    .4303426
>        LOGR1 |  -.0978866   .0795833    -1.23   0.220    -.2544537    .0586804
>        LOGR2 |   .0320762   .0604324     0.53   0.596    -.0868146     .150967
>        LOGR3 |  -.0203923    .072151    -0.28   0.778    -.1623375     .121553
>        LOGR4 |   .0162214   .0625026     0.26   0.795    -.1067422     .139185
>        LOGR5 |   -.009728   .0663792    -0.15   0.884    -.1403181    .1208621
>         LOGK |   .2071488   .1029215     2.01   0.045     .0046676      .40963
>      SCISECT |   .0176397   .3264891     0.05   0.957    -.6246739    .6599533
>       dyear2 |  -.0383927   .0179525    -2.14   0.033    -.0737113    -.003074
>       dyear3 |  -.0399403   .0253008    -1.58   0.115    -.0897155    .0098349
>       dyear4 |  -.1443278   .0319978    -4.51   0.000    -.2072783   -.0813773
>       dyear5 |  -.1957518   .0339705    -5.76   0.000    -.2625832   -.1289204
>        _cons |   1.661392   .5358439     3.10   0.002     .6072074    2.715577
> ------------------------------------------------------------------------------
> . estimates store NBFEjack
> 
> . lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5
>  ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 + [PAT]LOGR3 + [PAT]LOGR4 + [PAT]LOGR5 = 0
> ------------------------------------------------------------------------------
>          PAT |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>          (1) |   .1929697   .1136149     1.70   0.090    -.0305488    .4164883
> ------------------------------------------------------------------------------
> 
> */
. 
. *** TABLE 9.2: POOLED POISSON, POOLED GEE, POISSON FE, NB1 FE
. 
. * Note: Following gives default se's for NB1FE and not jackknife se's (given above)
. estimates table PCSclu PPAEXrob PFErob NBFEdef, b(%11.4f) se(%11.3f) stats(N ll) equations(1)

----------------------------------------------------------------------
    Variable |   PCSclu       PPAEXrob       PFErob        NBFEdef    
-------------+--------------------------------------------------------
        LOGR |      0.1345        0.3156        0.3222        0.2727  
             |       0.183         0.062         0.081         0.071  
       LOGR1 |     -0.0529       -0.0522       -0.0871       -0.0979  
             |       0.106         0.060         0.071         0.077  
       LOGR2 |      0.0082        0.1048        0.0786        0.0321  
             |       0.093         0.054         0.062         0.071  
       LOGR3 |      0.0661        0.0197        0.0011       -0.0204  
             |       0.114         0.067         0.078         0.066  
       LOGR4 |      0.0902        0.0230       -0.0046        0.0162  
             |       0.093         0.054         0.064         0.063  
       LOGR5 |      0.2395        0.0489        0.0026       -0.0097  
             |       0.123         0.055         0.076         0.053  
        LOGK |      0.2529        0.2699                      0.2071  
             |       0.059         0.057                       0.078  
     SCISECT |      0.4543        0.4402                      0.0176  
             |       0.167         0.175                       0.198  
      dyear2 |     -0.0435       -0.0456       -0.0426       -0.0384  
             |       0.018         0.017         0.017         0.024  
      dyear3 |     -0.0524       -0.0462       -0.0400       -0.0399  
             |       0.030         0.026         0.025         0.025  
      dyear4 |     -0.1702       -0.1686       -0.1571       -0.1443  
             |       0.046         0.041         0.036         0.026  
      dyear5 |     -0.2019       -0.2136       -0.1980       -0.1958  
             |       0.046         0.041         0.037         0.027  
       _cons |      0.8099        0.7774                      1.6614  
             |       0.242         0.245                       0.344  
-------------+--------------------------------------------------------
           N |        1730          1730          1620          1620  
          ll | -17834.1381                  -3536.3086    -3203.0644  
----------------------------------------------------------------------
                                                          legend: b/se

. 
. ********** 9.5 RANDOM EFFECTS MODELS
. 
. * There is no robust option for , re so need to bootstrap
. 
. * Poisson - gamma random effects
. xtpoisson PAT $XLIST, re

Fitting Poisson model:

Iteration 0:   log likelihood = -17836.658  
Iteration 1:   log likelihood = -17834.138  
Iteration 2:   log likelihood = -17834.138  

Fitting full model:

Iteration 0:   log likelihood = -5303.2636  
Iteration 1:   log likelihood =  -5241.765  
Iteration 2:   log likelihood = -5234.9526  
Iteration 3:   log likelihood = -5234.9265  
Iteration 4:   log likelihood = -5234.9265  

Random-effects Poisson regression               Number of obs      =      1730
Group variable: id                              Number of groups   =       346

Random effects u_i ~ Gamma                      Obs per group: min =         5
                                                               avg =       5.0
                                                               max =         5

                                                Wald chi2(12)      =   1272.14
Log likelihood  = -5234.9265                    Prob > chi2        =    0.0000

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        LOGR |   .4034537   .0435022     9.27   0.000      .318191    .4887165
       LOGR1 |  -.0461765   .0482224    -0.96   0.338    -.1406906    .0483376
       LOGR2 |   .1079235   .0447115     2.41   0.016     .0202905    .1955565
       LOGR3 |   .0297733   .0413235     0.72   0.471    -.0512193     .110766
       LOGR4 |   .0106957   .0377074     0.28   0.777    -.0632094    .0846008
       LOGR5 |   .0406111   .0315738     1.29   0.198    -.0212724    .1024946
        LOGK |   .2916932   .0393368     7.42   0.000     .2145945     .368792
     SCISECT |   .2570001   .1122716     2.29   0.022     .0369517    .4770484
      dyear2 |  -.0449624   .0131291    -3.42   0.001     -.070695   -.0192298
      dyear3 |  -.0483864   .0134018    -3.61   0.000    -.0746534   -.0221193
      dyear4 |  -.1741619   .0139702   -12.47   0.000     -.201543   -.1467809
      dyear5 |  -.2258977   .0146645   -15.40   0.000    -.2546396   -.1971557
       _cons |   .4107881   .1467443     2.80   0.005     .1231746    .6984016
-------------+----------------------------------------------------------------
    /lnalpha |   -.156739   .0809735                     -.3154441    .0019661
-------------+----------------------------------------------------------------
       alpha |   .8549271   .0692264                      .7294648    1.001968
------------------------------------------------------------------------------
Likelihood-ratio test of alpha=0: chibar2(01) =  2.5e+04 Prob>=chibar2 = 0.000

. estimates store PREdef

. * Following standard errors are preferred
. xtpoisson PAT $XLIST, re vce(boot, reps($BREPS) seed(10101))
(running xtpoisson on estimation sample)

Bootstrap replications (400)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
..................................................    50
..................................................   100
..................................................   150
..................................................   200
..................................................   250
..................................................   300
..................................................   350
..................................................   400

Random-effects Poisson regression               Number of obs      =      1730
Group variable: id                              Number of groups   =       346

Random effects u_i ~ Gamma                      Obs per group: min =         5
                                                               avg =       5.0
                                                               max =         5

                                                Wald chi2(12)      =   1295.42
Log likelihood  = -5234.9265                    Prob > chi2        =    0.0000

                                    (Replications based on 346 clusters in id)
------------------------------------------------------------------------------
             |   Observed   Bootstrap                         Normal-based
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        LOGR |   .4034537   .0809342     4.98   0.000     .2448256    .5620819
       LOGR1 |  -.0461765   .0767807    -0.60   0.548    -.1966639    .1043109
       LOGR2 |   .1079235   .0644214     1.68   0.094    -.0183402    .2341872
       LOGR3 |   .0297733   .0840982     0.35   0.723    -.1350561    .1946028
       LOGR4 |   .0106957   .0673302     0.16   0.874     -.121269    .1426604
       LOGR5 |   .0406111   .0760807     0.53   0.593    -.1085044    .1897266
        LOGK |   .2916932   .0768476     3.80   0.000     .1410747    .4423117
     SCISECT |   .2570001   .1357081     1.89   0.058     -.008983    .5229831
      dyear2 |  -.0449624   .0177426    -2.53   0.011    -.0797373   -.0101875
      dyear3 |  -.0483864   .0274466    -1.76   0.078    -.1021808    .0054081
      dyear4 |  -.1741619   .0388339    -4.48   0.000     -.250275   -.0980488
      dyear5 |  -.2258977   .0392428    -5.76   0.000    -.3028121   -.1489833
       _cons |   .4107881   .2262128     1.82   0.069     -.032581    .8541571
-------------+----------------------------------------------------------------
    /lnalpha |   -.156739   .0986191                     -.3500288    .0365508
-------------+----------------------------------------------------------------
       alpha |   .8549271   .0843121                      .7046678    1.037227
------------------------------------------------------------------------------
Likelihood-ratio test of alpha=0: chibar2(01) =  2.5e+04 Prob>=chibar2 = 0.000

. display "Table 9.3: first column Sum ln R"
Table 9.3: first column Sum ln R

. lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5

 ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 + [PAT]LOGR3 + [PAT]LOGR4 + [PAT]LOGR5 = 0

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .5462808   .0936551     5.83   0.000     .3627202    .7298415
------------------------------------------------------------------------------

. estimates store PRErob

. 
. * Poisson - normal random effects
. xtpoisson PAT $XLIST, re normal

Fitting comparison Poisson model:

Iteration 0:   log likelihood = -17836.658  
Iteration 1:   log likelihood = -17834.138  
Iteration 2:   log likelihood = -17834.138  

Fitting full model:

tau =  0.0     log likelihood = -17834.138
tau =  0.1     log likelihood = -6619.5905
tau =  0.2     log likelihood = -6432.6737
tau =  0.3     log likelihood =  -6612.791

Iteration 0:   log likelihood =  -5643.779  
Iteration 1:   log likelihood = -5273.0769  
Iteration 2:   log likelihood = -5246.4625  
Iteration 3:   log likelihood = -5245.0169  
Iteration 4:   log likelihood = -5245.0127  
Iteration 5:   log likelihood = -5245.0127  

Random-effects Poisson regression               Number of obs      =      1730
Group variable: id                              Number of groups   =       346

Random effects u_i ~ Gaussian                   Obs per group: min =         5
                                                               avg =       5.0
                                                               max =         5

                                                Wald chi2(12)      =   1206.64
Log likelihood  = -5245.0127                    Prob > chi2        =    0.0000

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        LOGR |   .4153326   .0435856     9.53   0.000     .3299063    .5007588
       LOGR1 |  -.0403106   .0482797    -0.83   0.404    -.1349371    .0543159
       LOGR2 |    .112102   .0447765     2.50   0.012     .0243416    .1998624
       LOGR3 |   .0348424   .0413625     0.84   0.400    -.0462266    .1159114
       LOGR4 |   .0126664   .0377112     0.34   0.737    -.0612462    .0865789
       LOGR5 |   .0471076   .0315904     1.49   0.136    -.0148084    .1090236
        LOGK |   .2917346   .0418194     6.98   0.000     .2097701    .3736991
     SCISECT |    .443509   .1236684     3.59   0.000     .2011233    .6858946
      dyear2 |  -.0453001   .0131302    -3.45   0.001    -.0710349   -.0195653
      dyear3 |  -.0496512   .0134031    -3.70   0.000    -.0759208   -.0233817
      dyear4 |  -.1766992   .0139747   -12.64   0.000    -.2040892   -.1493093
      dyear5 |  -.2301051   .0146847   -15.67   0.000    -.2588867   -.2013236
       _cons |  -.1513461   .1687456    -0.90   0.370    -.4820813    .1793892
-------------+----------------------------------------------------------------
    /lnsig2u |  -.0052583   .0954254    -0.06   0.956    -.1922887    .1817721
-------------+----------------------------------------------------------------
     sigma_u |   .9973743   .0475874                      .9083329    1.095144
------------------------------------------------------------------------------
Likelihood-ratio test of sigma_u=0: chibar2(01) =  2.5e+04 Pr>=chibar2 = 0.000

. estimates store PRENdef

. lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5

 ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 + [PAT]LOGR3 + [PAT]LOGR4 + [PAT]LOGR5 = 0

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .5817403   .0409286    14.21   0.000     .5015218    .6619588
------------------------------------------------------------------------------

. * Following standard errors are preferred
. * This took a long time so is comment out
. * xtpoisson PAT $XLIST, re normal vce(jackknife)
. * estimates store PRENrob
. * display "Table 9.3: second column Sum ln R"
. * lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5
. * or ..
. * Note that about 20% of bootstrap replications failed to estimate
. * xtpoisson PAT $XLIST, re normal vce(boot, reps($BREPS) seed(10101))
. * lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5
. 
. /* JACKKNIFE
> . xtpoisson PAT $XLIST, re normal vce(jackknife)
> (running xtpoisson on estimation sample)
> Jackknife replications (346)
> ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
> ..................................................    50
> ..................................................   100
> ...x..............................................   150
> ..................................................   200
> ..................................................   250
> ..................................................   300
> ..............................................
> Random-effects Poisson regression               Number of obs      =      1730
> Group variable: id                              Number of groups   =       346
> Random effects u_i ~ Gaussian                   Obs per group: min =         5
>                                                                avg =       5.0
>                                                                max =         5
>                                                 F(    12,     344) =     94.88
> Log likelihood  = -5245.0127                    Prob > F           =    0.0000
>                                     (Replications based on 346 clusters in id)
> ------------------------------------------------------------------------------
>              |              Jackknife
>          PAT |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>         LOGR |   .4153326   .0781077     5.32   0.000     .2617038    .5689614
>        LOGR1 |  -.0403106   .0744648    -0.54   0.589    -.1867743    .1061531
>        LOGR2 |    .112102   .0649979     1.72   0.085    -.0157413    .2399453
>        LOGR3 |   .0348424   .0886451     0.39   0.695    -.1395122     .209197
>        LOGR4 |   .0126664   .0669306     0.19   0.850    -.1189783     .144311
>        LOGR5 |   .0471076   .0794252     0.59   0.553    -.1091126    .2033278
>         LOGK |   .2917346   .0834706     3.50   0.001     .1275577    .4559115
>      SCISECT |    .443509   .1527652     2.90   0.004     .1430375    .7439805
>       dyear2 |  -.0453001   .0180533    -2.51   0.013    -.0808088   -.0097914
>       dyear3 |  -.0496512   .0270002    -1.84   0.067    -.1027575     .003455
>       dyear4 |  -.1766992   .0398763    -4.43   0.000    -.2551313   -.0982671
>       dyear5 |  -.2301051   .0389316    -5.91   0.000     -.306679   -.1535312
>        _cons |  -.1513461   .2729969    -0.55   0.580    -.6882993    .3856072
> -------------+----------------------------------------------------------------
>     /lnsig2u |  -.0052583   .1107198    -0.05   0.962    -.2230313    .2125146
> -------------+----------------------------------------------------------------
>      sigma_u |   .9973743   .0552145                      .8944774    1.112108
> ------------------------------------------------------------------------------
> Likelihood-ratio test of sigma_u=0: chibar2(01) =  2.5e+04 Pr>=chibar2 = 0.000
> . lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5
>  ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 + [PAT]LOGR3 + [PAT]LOGR4 + [PAT]LOGR5 = 0
> ------------------------------------------------------------------------------
>          PAT |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>          (1) |   .5817403   .0977223     5.95   0.000     .3895319    .7739487
> ------------------------------------------------------------------------------
> */
. 
. /* BOOTSTRAP FOR POISSON RE NORMAL FAILED MANY TIMES
> . xtpoisson PAT $XLIST, re normal vce(boot, reps($BREPS) seed(10101))
> (running xtpoisson on estimation sample)
> Bootstrap replications (400)
> ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
> x...x..x..xx..x.xx....x...........x.............x.    50
> ......x...x......x.x.xx.xx..x...x.....x....x.x....   100
> .x...................x.....x...x..x....x..x.......   150
> ..............x........x...x..x..........x...x....   200
> .........x.......x....x...x...xx..xxx.....xx....x.   250
> xx.x.........x.x.x........x............x........x.   300
> .x.....x....................x.x..........x.....x.x   350
> x.........x..x...x.....x........x.....x...........   400
> Random-effects Poisson regression               Number of obs      =      1730
> Group variable: id                              Number of groups   =       346
> Random effects u_i ~ Gaussian                   Obs per group: min =         5
>                                                                avg =       5.0
>                                                                max =         5
>                                                 Wald chi2(12)      =   1202.83
> Log likelihood  = -5245.0127                    Prob > chi2        =    0.0000
>                                     (Replications based on 346 clusters in id)
> ------------------------------------------------------------------------------
>              |   Observed   Bootstrap                         Normal-based
>          PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>         LOGR |   .4153326   .0816933     5.08   0.000     .2552166    .5754485
>        LOGR1 |  -.0403106   .0779906    -0.52   0.605    -.1931694    .1125482
>        LOGR2 |    .112102   .0632054     1.77   0.076    -.0117782    .2359822
>        LOGR3 |   .0348424   .0842935     0.41   0.679    -.1303698    .2000546
>        LOGR4 |   .0126664    .066196     0.19   0.848    -.1170754    .1424082
>        LOGR5 |   .0471076   .0728772     0.65   0.518     -.095729    .1899442
>         LOGK |   .2917346   .0782631     3.73   0.000     .1383418    .4451274
>      SCISECT |    .443509   .1454438     3.05   0.002     .1584444    .7285735
>       dyear2 |  -.0453001   .0181748    -2.49   0.013    -.0809221   -.0096781
>       dyear3 |  -.0496512   .0274114    -1.81   0.070    -.1033767    .0040742
>       dyear4 |  -.1766992   .0383587    -4.61   0.000     -.251881   -.1015175
>       dyear5 |  -.2301051   .0379868    -6.06   0.000    -.3045579   -.1556523
>        _cons |  -.1513461   .2651781    -0.57   0.568    -.6710856    .3683935
> -------------+----------------------------------------------------------------
>     /lnsig2u |  -.0052583    .120223    -0.04   0.965     -.240891    .2303744
> -------------+----------------------------------------------------------------
>      sigma_u |   .9973743   .0599537                      .8865254    1.122083
> ------------------------------------------------------------------------------
> Likelihood-ratio test of sigma_u=0: chibar2(01) =  2.5e+04 Pr>=chibar2 = 0.000
> . estimates store PRENrob
> . display "Table 9.3: second column Sum ln R"
> Table 9.3: second column Sum ln R
> . lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5
>  ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 + [PAT]LOGR3 + [PAT]LOGR4 + [PAT]LOGR5 = 0
> ------------------------------------------------------------------------------
>          PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>          (1) |   .5817403   .0909148     6.40   0.000     .4035506      .75993
> ------------------------------------------------------------------------------
> */
. 
. /* SO INSTEAD PANEL JACKKNIFE FOR POISSON RE NORMAL
>    THESE ARE THE STANDARD ERRORS IN TABLE 9.3 FOR POISSON RE NORMAL
> . xtpoisson PAT $XLIST, re normal vce(jackknife)
> (running xtpoisson on estimation sample)
> Jackknife replications (346)
> ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
> ..................................................    50
> ..................................................   100
> ...x..............................................   150
> ..................................................   200
> ..................................................   250
> ..................................................   300
> ..............................................
> Random-effects Poisson regression               Number of obs      =      1730
> Group variable: id                              Number of groups   =       346
> 
> Random effects u_i ~ Gaussian                   Obs per group: min =         5
>                                                                avg =       5.0
>                                                                max =         5
>                                                 F(    12,     344) =     94.88
> Log likelihood  = -5245.0127                    Prob > F           =    0.0000
>                                     (Replications based on 346 clusters in id)
> ------------------------------------------------------------------------------
>              |              Jackknife
>          PAT |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>         LOGR |   .4153326   .0781077     5.32   0.000     .2617038    .5689614
>        LOGR1 |  -.0403106   .0744648    -0.54   0.589    -.1867743    .1061531
>        LOGR2 |    .112102   .0649979     1.72   0.085    -.0157413    .2399453
>        LOGR3 |   .0348424   .0886451     0.39   0.695    -.1395122     .209197
>        LOGR4 |   .0126664   .0669306     0.19   0.850    -.1189783     .144311
>        LOGR5 |   .0471076   .0794252     0.59   0.553    -.1091126    .2033278
>         LOGK |   .2917346   .0834706     3.50   0.001     .1275577    .4559115
>      SCISECT |    .443509   .1527652     2.90   0.004     .1430375    .7439805
>       dyear2 |  -.0453001   .0180533    -2.51   0.013    -.0808088   -.0097914
>       dyear3 |  -.0496512   .0270002    -1.84   0.067    -.1027575     .003455
>       dyear4 |  -.1766992   .0398763    -4.43   0.000    -.2551313   -.0982671
>       dyear5 |  -.2301051   .0389316    -5.91   0.000     -.306679   -.1535312
>        _cons |  -.1513461   .2729969    -0.55   0.580    -.6882993    .3856072
> -------------+----------------------------------------------------------------
>     /lnsig2u |  -.0052583   .1107198    -0.05   0.962    -.2230313    .2125146
> -------------+----------------------------------------------------------------
>      sigma_u |   .9973743   .0552145                      .8944774    1.112108
> ------------------------------------------------------------------------------
> Likelihood-ratio test of sigma_u=0: chibar2(01) =  2.5e+04 Pr>=chibar2 = 0.000
> 
> . lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5
>  ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 + [PAT]LOGR3 + [PAT]LOGR4 + [PAT]LOGR5 = 0
> 
> ------------------------------------------------------------------------------
>          PAT |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
> -------------+----------------------------------------------------------------
>          (1) |   .5817403   .0977223     5.95   0.000     .3895319    .7739487
> ------------------------------------------------------------------------------
> */
. 
. * Negative binomial - beta distributed ratio random effects
. xtnbreg PAT $XLIST, re

Fitting negative binomial (constant dispersion) model:

Iteration 0:   log likelihood = -17836.658  
Iteration 1:   log likelihood = -17834.138  
Iteration 2:   log likelihood = -17834.138  

Iteration 0:   log likelihood = -37163.276  
Iteration 1:   log likelihood = -17331.718  
Iteration 2:   log likelihood =  -8376.139  (backed up)
Iteration 3:   log likelihood = -6999.1967  
Iteration 4:   log likelihood = -6948.0162  
Iteration 5:   log likelihood = -6948.0022  
Iteration 6:   log likelihood = -6948.0022  

Iteration 0:   log likelihood = -6948.0022  
Iteration 1:   log likelihood = -6484.3647  (not concave)
Iteration 2:   log likelihood = -6063.4801  
Iteration 3:   log likelihood = -5996.6042  
Iteration 4:   log likelihood = -5954.4866  
Iteration 5:   log likelihood = -5954.1073  
Iteration 6:   log likelihood = -5954.1071  

Fitting full model:

Iteration 0:   log likelihood =  -5074.487  
Iteration 1:   log likelihood = -4961.2657  
Iteration 2:   log likelihood = -4948.6428  
Iteration 3:   log likelihood = -4948.4945  
Iteration 4:   log likelihood = -4948.4944  

Random-effects negative binomial regression     Number of obs      =      1730
Group variable: id                              Number of groups   =       346

Random effects u_i ~ Beta                       Obs per group: min =         5
                                                               avg =       5.0
                                                               max =         5

                                                Wald chi2(12)      =    944.21
Log likelihood  = -4948.4944                    Prob > chi2        =    0.0000

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        LOGR |   .3503119   .0652818     5.37   0.000     .2223619    .4782619
       LOGR1 |  -.0030317   .0750916    -0.04   0.968    -.1502085    .1441452
       LOGR2 |   .1049876   .0688488     1.52   0.127    -.0299537    .2399289
       LOGR3 |   .0163523   .0636376     0.26   0.797    -.1083752    .1410797
       LOGR4 |   .0359425   .0587161     0.61   0.540    -.0791389    .1510239
       LOGR5 |   .0718323   .0482887     1.49   0.137    -.0228119    .1664764
        LOGK |    .161937   .0417874     3.88   0.000     .0800351    .2438388
     SCISECT |   .1176419   .1066164     1.10   0.270    -.0913224    .3266063
      dyear2 |  -.0436736   .0213435    -2.05   0.041     -.085506   -.0018411
      dyear3 |  -.0556597   .0218572    -2.55   0.011     -.098499   -.0128203
      dyear4 |  -.1831055   .0227183    -8.06   0.000    -.2276326   -.1385784
      dyear5 |  -.2300438   .0231525    -9.94   0.000    -.2754219   -.1846658
       _cons |   .8995618   .1681113     5.35   0.000     .5700698    1.229054
-------------+----------------------------------------------------------------
       /ln_r |   .9877591   .0961426                      .7993231    1.176195
       /ln_s |   .7009608   .1079684                      .4893467    .9125748
-------------+----------------------------------------------------------------
           r |    2.68521   .2581631                      2.224035    3.242015
           s |   2.015688   .2176306                       1.63125    2.490728
------------------------------------------------------------------------------
Likelihood-ratio test vs. pooled: chibar2(01) =  2011.23 Prob>=chibar2 = 0.000

. estimates store NBREdef

. * Following standard errors are preferred
. xtnbreg PAT $XLIST, re vce(boot, reps($BREPS) seed(10101))
(running xtnbreg on estimation sample)

Bootstrap replications (400)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
..................................................    50
..................................................   100
..................................................   150
..................................................   200
..................................................   250
..................................................   300
..................................................   350
..................................................   400

Random-effects negative binomial regression     Number of obs      =      1730
Group variable: id                              Number of groups   =       346

Random effects u_i ~ Beta                       Obs per group: min =         5
                                                               avg =       5.0
                                                               max =         5

                                                Wald chi2(12)      =    479.91
Log likelihood  = -4948.4944                    Prob > chi2        =    0.0000

                                    (Replications based on 346 clusters in id)
------------------------------------------------------------------------------
             |   Observed   Bootstrap                         Normal-based
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        LOGR |   .3503119   .0715707     4.89   0.000     .2100359    .4905879
       LOGR1 |  -.0030317   .0722299    -0.04   0.967    -.1445996    .1385362
       LOGR2 |   .1049876   .0580511     1.81   0.071    -.0087904    .2187656
       LOGR3 |   .0163523   .0769153     0.21   0.832     -.134399    .1671035
       LOGR4 |   .0359425   .0590841     0.61   0.543    -.0798602    .1517451
       LOGR5 |   .0718323   .0607418     1.18   0.237    -.0472195    .1908841
        LOGK |    .161937   .0539557     3.00   0.003     .0561857    .2676883
     SCISECT |   .1176419   .1391107     0.85   0.398    -.1550101    .3902939
      dyear2 |  -.0436736   .0174441    -2.50   0.012    -.0778634   -.0094837
      dyear3 |  -.0556597   .0257636    -2.16   0.031    -.1061554    -.005164
      dyear4 |  -.1831055   .0355249    -5.15   0.000    -.2527331   -.1134779
      dyear5 |  -.2300438   .0364212    -6.32   0.000    -.3014281   -.1586596
       _cons |   .8995618   .2145383     4.19   0.000     .4790745    1.320049
-------------+----------------------------------------------------------------
       /ln_r |   .9877591   .1620609                      .6701257    1.305393
       /ln_s |   .7009608   .1298822                      .4463964    .9555251
-------------+----------------------------------------------------------------
           r |    2.68521   .4351675                      1.954483    3.689137
           s |   2.015688    .261802                      1.562671    2.600036
------------------------------------------------------------------------------
Likelihood-ratio test vs. pooled: chibar2(01) =  2011.23 Prob>=chibar2 = 0.000

. estimates store NBRErob

. display "Table 9.3: third column Sum ln R"
Table 9.3: third column Sum ln R

. lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5

 ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 + [PAT]LOGR3 + [PAT]LOGR4 + [PAT]LOGR5 = 0

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .5763948   .0703515     8.19   0.000     .4385084    .7142813
------------------------------------------------------------------------------

. * There is no RE normal option for xtnbreg
. 
. estimates table PREdef PRErob PRENdef NBREdef NBRErob, b(%11.4f) se(%11.3f) stats(N ll)

------------------------------------------------------------------------------------
    Variable |   PREdef        PRErob        PRENdef       NBREdef       NBRErob    
-------------+----------------------------------------------------------------------
PAT          |
        LOGR |      0.4035        0.4035        0.4153        0.3503        0.3503  
             |       0.044         0.081         0.044         0.065         0.072  
       LOGR1 |     -0.0462       -0.0462       -0.0403       -0.0030       -0.0030  
             |       0.048         0.077         0.048         0.075         0.072  
       LOGR2 |      0.1079        0.1079        0.1121        0.1050        0.1050  
             |       0.045         0.064         0.045         0.069         0.058  
       LOGR3 |      0.0298        0.0298        0.0348        0.0164        0.0164  
             |       0.041         0.084         0.041         0.064         0.077  
       LOGR4 |      0.0107        0.0107        0.0127        0.0359        0.0359  
             |       0.038         0.067         0.038         0.059         0.059  
       LOGR5 |      0.0406        0.0406        0.0471        0.0718        0.0718  
             |       0.032         0.076         0.032         0.048         0.061  
        LOGK |      0.2917        0.2917        0.2917        0.1619        0.1619  
             |       0.039         0.077         0.042         0.042         0.054  
     SCISECT |      0.2570        0.2570        0.4435        0.1176        0.1176  
             |       0.112         0.136         0.124         0.107         0.139  
      dyear2 |     -0.0450       -0.0450       -0.0453       -0.0437       -0.0437  
             |       0.013         0.018         0.013         0.021         0.017  
      dyear3 |     -0.0484       -0.0484       -0.0497       -0.0557       -0.0557  
             |       0.013         0.027         0.013         0.022         0.026  
      dyear4 |     -0.1742       -0.1742       -0.1767       -0.1831       -0.1831  
             |       0.014         0.039         0.014         0.023         0.036  
      dyear5 |     -0.2259       -0.2259       -0.2301       -0.2300       -0.2300  
             |       0.015         0.039         0.015         0.023         0.036  
       _cons |      0.4108        0.4108       -0.1513        0.8996        0.8996  
             |       0.147         0.226         0.169         0.168         0.215  
-------------+----------------------------------------------------------------------
lnalpha      |
       _cons |     -0.1567       -0.1567                                            
             |       0.081         0.099                                            
-------------+----------------------------------------------------------------------
lnsig2u      |
       _cons |                                 -0.0053                              
             |                                   0.095                              
-------------+----------------------------------------------------------------------
ln_r         |
       _cons |                                                0.9878        0.9878  
             |                                                 0.096         0.162  
-------------+----------------------------------------------------------------------
ln_s         |
       _cons |                                                0.7010        0.7010  
             |                                                 0.108         0.130  
-------------+----------------------------------------------------------------------
Statistics   |                                                                      
           N |        1730          1730          1730          1730          1730  
          ll |  -5234.9265    -5234.9265    -5245.0127    -4948.4944    -4948.4944  
------------------------------------------------------------------------------------
                                                                        legend: b/se

. 
. * Conditionally Correlated Random Effects
. sort id

. by id: egen LOGRMEAN = mean(LOGR)

. by id: egen LOGR1MEAN = mean(LOGR1)

. by id: egen LOGR2MEAN = mean(LOGR2)

. by id: egen LOGR3MEAN = mean(LOGR3)

. by id: egen LOGR4MEAN = mean(LOGR4)

. by id: egen LOGR5MEAN = mean(LOGR5)

. global MEANS LOGRMEAN LOGR1MEAN LOGR2MEAN LOGR3MEAN LOGR4MEAN LOGR5MEAN

. 
. * Poisson CCRE 
. xtpoisson PAT $XLIST $MEANS, re

Fitting Poisson model:

Iteration 0:   log likelihood = -17636.972  
Iteration 1:   log likelihood = -17631.366  
Iteration 2:   log likelihood = -17631.366  

Fitting full model:

Iteration 0:   log likelihood = -5248.2202  
Iteration 1:   log likelihood = -5214.6644  
Iteration 2:   log likelihood = -5211.9092  
Iteration 3:   log likelihood =  -5211.898  
Iteration 4:   log likelihood =  -5211.898  

Random-effects Poisson regression               Number of obs      =      1730
Group variable: id                              Number of groups   =       346

Random effects u_i ~ Gamma                      Obs per group: min =         5
                                                               avg =       5.0
                                                               max =         5

                                                Wald chi2(18)      =   1367.27
Log likelihood  =  -5211.898                    Prob > chi2        =    0.0000

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        LOGR |   .3216624   .0459496     7.00   0.000     .2316029    .4117219
       LOGR1 |  -.0871244   .0487055    -1.79   0.074    -.1825855    .0083367
       LOGR2 |   .0788715    .044789     1.76   0.078    -.0089133    .1666564
       LOGR3 |   .0004448   .0414296     0.01   0.991    -.0807558    .0816454
       LOGR4 |  -.0047836   .0378581    -0.13   0.899     -.078984    .0694168
       LOGR5 |   .0024365   .0322758     0.08   0.940     -.060823    .0656959
        LOGK |   .0617355   .0496748     1.24   0.214    -.0356252    .1590963
     SCISECT |  -.0489817   .1190747    -0.41   0.681    -.2823639    .1844004
      dyear2 |  -.0425778   .0131311    -3.24   0.001    -.0683142   -.0168414
      dyear3 |  -.0399678   .0134663    -2.97   0.003    -.0663612   -.0135744
      dyear4 |  -.1570141   .0142265   -11.04   0.000    -.1848974   -.1291307
      dyear5 |  -.1978545   .0152893   -12.94   0.000    -.2278209   -.1678881
    LOGRMEAN |   .1288205   .7395089     0.17   0.862     -1.32059    1.578231
   LOGR1MEAN |    .337339    1.50528     0.22   0.823    -2.612956    3.287634
   LOGR2MEAN |  -1.058057   1.695896    -0.62   0.533    -4.381953    2.265838
   LOGR3MEAN |   .4736023   1.473157     0.32   0.748    -2.413731    3.360936
   LOGR4MEAN |   .8514155   1.125538     0.76   0.449    -1.354599     3.05743
   LOGR5MEAN |  -.1953429   .5483733    -0.36   0.722    -1.270135     .879449
       _cons |   1.038369   .1737466     5.98   0.000     .6978321    1.378906
-------------+----------------------------------------------------------------
    /lnalpha |  -.2324255   .0796859                      -.388607    -.076244
-------------+----------------------------------------------------------------
       alpha |   .7926088   .0631597                      .6780007    .9265901
------------------------------------------------------------------------------
Likelihood-ratio test of alpha=0: chibar2(01) =  2.5e+04 Prob>=chibar2 = 0.000

. estimates store PCCREdef

. * Following standard errors are preferred
. xtpoisson PAT $XLIST $MEANS, re vce(boot, reps($BREPS) seed(10101))
(running xtpoisson on estimation sample)

Bootstrap replications (400)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
..................................................    50
..................................................   100
..................................................   150
..................................................   200
..................................................   250
..................................................   300
..................................................   350
..................................................   400

Random-effects Poisson regression               Number of obs      =      1730
Group variable: id                              Number of groups   =       346

Random effects u_i ~ Gamma                      Obs per group: min =         5
                                                               avg =       5.0
                                                               max =         5

                                                Wald chi2(18)      =   1338.07
Log likelihood  =  -5211.898                    Prob > chi2        =    0.0000

                                    (Replications based on 346 clusters in id)
------------------------------------------------------------------------------
             |   Observed   Bootstrap                         Normal-based
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        LOGR |   .3216624   .0893443     3.60   0.000     .1465509     .496774
       LOGR1 |  -.0871244   .0759254    -1.15   0.251    -.2359355    .0616866
       LOGR2 |   .0788715   .0646599     1.22   0.223    -.0478595    .2056025
       LOGR3 |   .0004448   .0823245     0.01   0.996    -.1609083    .1617978
       LOGR4 |  -.0047836   .0694973    -0.07   0.945    -.1409959    .1314287
       LOGR5 |   .0024365    .080477     0.03   0.976    -.1552955    .1601685
        LOGK |   .0617355   .0604269     1.02   0.307    -.0566991    .1801701
     SCISECT |  -.0489817   .1213592    -0.40   0.686    -.2868415     .188878
      dyear2 |  -.0425778   .0175546    -2.43   0.015    -.0769841   -.0081715
      dyear3 |  -.0399678   .0273004    -1.46   0.143    -.0934757    .0135401
      dyear4 |  -.1570141   .0374605    -4.19   0.000    -.2304353   -.0835928
      dyear5 |  -.1978545   .0399262    -4.96   0.000    -.2761084   -.1196006
    LOGRMEAN |   .1288205   .8918764     0.14   0.885    -1.619225    1.876866
   LOGR1MEAN |    .337339   1.908554     0.18   0.860    -3.403358    4.078036
   LOGR2MEAN |  -1.058057   2.153485    -0.49   0.623    -5.278811    3.162696
   LOGR3MEAN |   .4736023   1.778131     0.27   0.790     -3.01147    3.958675
   LOGR4MEAN |   .8514155   1.306418     0.65   0.515    -1.709117    3.411948
   LOGR5MEAN |  -.1953429   .5789217    -0.34   0.736    -1.330009    .9393229
       _cons |   1.038369   .1958001     5.30   0.000     .6546079     1.42213
-------------+----------------------------------------------------------------
    /lnalpha |  -.2324255   .0872308                     -.4033948   -.0614563
-------------+----------------------------------------------------------------
       alpha |   .7926088   .0691399                      .6680483    .9403941
------------------------------------------------------------------------------
Likelihood-ratio test of alpha=0: chibar2(01) =  2.5e+04 Prob>=chibar2 = 0.000

. estimates store PCCRErob

. display "Table 9.3: fourth column Sum ln R"
Table 9.3: fourth column Sum ln R

. lincom LOGR + LOGR1 + LOGR2 + LOGR3 + LOGR4 + LOGR5

 ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 + [PAT]LOGR3 + [PAT]LOGR4 + [PAT]LOGR5 = 0

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .3115071   .1451475     2.15   0.032     .0270233     .595991
------------------------------------------------------------------------------

. 
. *** TABLE 9.3: RANDOM EFFECTS - Poisson-gamma, Poisson-normal, NB, CCRE
. * For Poisson RE - normal default se's given here to speed up program
. * See the panel kackknife above for correct se's
. estimates table PRErob PRENdef NBRErob PCCRErob, b(%11.4f) se(%11.3f) stats(N ll)

----------------------------------------------------------------------
    Variable |   PRErob        PRENdef       NBRErob      PCCRErob    
-------------+--------------------------------------------------------
PAT          |
        LOGR |      0.4035        0.4153        0.3503        0.3217  
             |       0.081         0.044         0.072         0.089  
       LOGR1 |     -0.0462       -0.0403       -0.0030       -0.0871  
             |       0.077         0.048         0.072         0.076  
       LOGR2 |      0.1079        0.1121        0.1050        0.0789  
             |       0.064         0.045         0.058         0.065  
       LOGR3 |      0.0298        0.0348        0.0164        0.0004  
             |       0.084         0.041         0.077         0.082  
       LOGR4 |      0.0107        0.0127        0.0359       -0.0048  
             |       0.067         0.038         0.059         0.069  
       LOGR5 |      0.0406        0.0471        0.0718        0.0024  
             |       0.076         0.032         0.061         0.080  
        LOGK |      0.2917        0.2917        0.1619        0.0617  
             |       0.077         0.042         0.054         0.060  
     SCISECT |      0.2570        0.4435        0.1176       -0.0490  
             |       0.136         0.124         0.139         0.121  
      dyear2 |     -0.0450       -0.0453       -0.0437       -0.0426  
             |       0.018         0.013         0.017         0.018  
      dyear3 |     -0.0484       -0.0497       -0.0557       -0.0400  
             |       0.027         0.013         0.026         0.027  
      dyear4 |     -0.1742       -0.1767       -0.1831       -0.1570  
             |       0.039         0.014         0.036         0.037  
      dyear5 |     -0.2259       -0.2301       -0.2300       -0.1979  
             |       0.039         0.015         0.036         0.040  
    LOGRMEAN |                                                0.1288  
             |                                                 0.892  
   LOGR1MEAN |                                                0.3373  
             |                                                 1.909  
   LOGR2MEAN |                                               -1.0581  
             |                                                 2.153  
   LOGR3MEAN |                                                0.4736  
             |                                                 1.778  
   LOGR4MEAN |                                                0.8514  
             |                                                 1.306  
   LOGR5MEAN |                                               -0.1953  
             |                                                 0.579  
       _cons |      0.4108       -0.1513        0.8996        1.0384  
             |       0.226         0.169         0.215         0.196  
-------------+--------------------------------------------------------
lnalpha      |
       _cons |     -0.1567                                   -0.2324  
             |       0.099                                     0.087  
-------------+--------------------------------------------------------
lnsig2u      |
       _cons |                   -0.0053                              
             |                     0.095                              
-------------+--------------------------------------------------------
ln_r         |
       _cons |                                  0.9878                
             |                                   0.162                
-------------+--------------------------------------------------------
ln_s         |
       _cons |                                  0.7010                
             |                                   0.130                
-------------+--------------------------------------------------------
Statistics   |                                                        
           N |        1730          1730          1730          1730  
          ll |  -5234.9265    -5245.0127    -4948.4944    -5211.8980  
----------------------------------------------------------------------
                                                          legend: b/se

. 
. ********* DYNAMIC MODELS USING EXPONENTIAL FEEDBACK MODEL
. 
. * Add PAT lagged once as regressor
. * And now have just two lags of LOGR as regressors
. global XLISTD PAT1 LOGR LOGR1 LOGR2 LOGK SCISECT dyear2 dyear3 dyear4 dyear5

. 
. * Pooled Poisson
. poisson PAT $XLISTD, vce(cluster id)

Iteration 0:   log pseudolikelihood =  -280117.7  
Iteration 1:   log pseudolikelihood = -137135.22  
Iteration 2:   log pseudolikelihood = -52736.981  
Iteration 3:   log pseudolikelihood = -18503.228  
Iteration 4:   log pseudolikelihood = -14743.431  
Iteration 5:   log pseudolikelihood = -14717.192  
Iteration 6:   log pseudolikelihood = -14717.183  
Iteration 7:   log pseudolikelihood = -14717.183  

Poisson regression                                Number of obs   =       1730
                                                  Wald chi2(10)   =     671.99
                                                  Prob > chi2     =     0.0000
Log pseudolikelihood = -14717.183                 Pseudo R2       =     0.8045

                                   (Std. Err. adjusted for 346 clusters in id)
------------------------------------------------------------------------------
             |               Robust
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        PAT1 |   .0033814   .0006154     5.49   0.000     .0021753    .0045875
        LOGR |   .3590677   .1435441     2.50   0.012     .0777264     .640409
       LOGR1 |  -.1592754   .1004438    -1.59   0.113    -.3561416    .0375908
       LOGR2 |    .133313    .138718     0.96   0.337    -.1385693    .4051953
        LOGK |   .1831944   .0459439     3.99   0.000      .093146    .2732428
     SCISECT |    .288793   .1354546     2.13   0.033     .0233069    .5542792
      dyear2 |  -.0424498   .0380379    -1.12   0.264    -.1170026    .0321031
      dyear3 |   -.007469   .0367145    -0.20   0.839     -.079428      .06449
      dyear4 |  -.1213673   .0466182    -2.60   0.009    -.2127373   -.0299973
      dyear5 |  -.1104694   .0429585    -2.57   0.010    -.1946665   -.0262724
       _cons |   1.329976   .2099348     6.34   0.000     .9185113     1.74144
------------------------------------------------------------------------------

. estimates store DPCS

. display "Table 9.5: first column Sum ln R"
Table 9.5: first column Sum ln R

. lincom LOGR + LOGR1 + LOGR2

 ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 = 0

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .3331053   .0617574     5.39   0.000     .2120631    .4541475
------------------------------------------------------------------------------

. 
. * Population Averaged Poisson with exchangeable errors
. * Following standard errors are preferred
. xtpoisson PAT $XLISTD, pa vce(robust)

Iteration 1: tolerance = .07257923
Iteration 2: tolerance = .01848274
Iteration 3: tolerance = .00150935
Iteration 4: tolerance = .00009856
Iteration 5: tolerance = 4.114e-06
Iteration 6: tolerance = 2.943e-07

GEE population-averaged model                   Number of obs      =      1730
Group variable:                         id      Number of groups   =       346
Link:                                  log      Obs per group: min =         5
Family:                            Poisson                     avg =       5.0
Correlation:                  exchangeable                     max =         5
                                                Wald chi2(10)      =    507.36
Scale parameter:                         1      Prob > chi2        =    0.0000

                                     (Std. Err. adjusted for clustering on id)
------------------------------------------------------------------------------
             |               Robust
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        PAT1 |   .0018599   .0003348     5.55   0.000     .0012036    .0025161
        LOGR |   .3788088   .0661193     5.73   0.000     .2492173    .5084003
       LOGR1 |  -.0801661   .0742112    -1.08   0.280    -.2256175    .0652852
       LOGR2 |   .0778156   .0586969     1.33   0.185    -.0372282    .1928595
        LOGK |   .2228567   .0448267     4.97   0.000     .1349979    .3107154
     SCISECT |   .3706687    .155546     2.38   0.017     .0658041    .6755333
      dyear2 |  -.0439155   .0237863    -1.85   0.065    -.0905358    .0027047
      dyear3 |  -.0323041   .0256807    -1.26   0.208    -.0826372    .0180291
      dyear4 |  -.1543135   .0384815    -4.01   0.000    -.2297359    -.078891
      dyear5 |  -.1694393   .0349305    -4.85   0.000    -.2379018   -.1009767
       _cons |   1.117729   .2222871     5.03   0.000     .6820544    1.553404
------------------------------------------------------------------------------

. display "Table 9.5: second column Sum ln R"
Table 9.5: second column Sum ln R

. lincom LOGR + LOGR1 + LOGR2

 ( 1)  LOGR + LOGR1 + LOGR2 = 0

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .3764583   .0531352     7.08   0.000     .2723151    .4806015
------------------------------------------------------------------------------

. 
. * Poisson Random Effects - gamma
. estimates store DPPA

. xtpoisson PAT $XLISTD, re vce(boot, reps($BREPS) seed(10101))
(running xtpoisson on estimation sample)

Bootstrap replications (400)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
..................................................    50
..................................................   100
..................................................   150
..................................................   200
..................................................   250
..................................................   300
..................................................   350
..................................................   400

Random-effects Poisson regression               Number of obs      =      1730
Group variable: id                              Number of groups   =       346

Random effects u_i ~ Gamma                      Obs per group: min =         5
                                                               avg =       5.0
                                                               max =         5

                                                Wald chi2(10)      =   1330.22
Log likelihood  = -5188.0204                    Prob > chi2        =    0.0000

                                    (Replications based on 346 clusters in id)
------------------------------------------------------------------------------
             |   Observed   Bootstrap                         Normal-based
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        PAT1 |   .0012825   .0005778     2.22   0.026     .0001501     .002415
        LOGR |     .44618   .0797825     5.59   0.000     .2898091    .6025508
       LOGR1 |  -.0595111   .0904428    -0.66   0.511    -.2367757    .1177535
       LOGR2 |   .1032655   .0660265     1.56   0.118     -.026144     .232675
        LOGK |   .3001179   .0553427     5.42   0.000     .1916483    .4085875
     SCISECT |   .2804724    .116429     2.41   0.016     .0522757    .5086691
      dyear2 |  -.0463529   .0221779    -2.09   0.037    -.0898207   -.0028851
      dyear3 |  -.0416408   .0271882    -1.53   0.126    -.0949288    .0116472
      dyear4 |  -.1680358    .037999    -4.42   0.000    -.2425125   -.0935591
      dyear5 |  -.1963685   .0360068    -5.45   0.000    -.2669405   -.1257964
       _cons |   .3724811   .1780802     2.09   0.036     .0234502    .7215119
-------------+----------------------------------------------------------------
    /lnalpha |   -.180793   .0945499                     -.3661075    .0045215
-------------+----------------------------------------------------------------
       alpha |   .8346081   .0789122                      .6934283    1.004532
------------------------------------------------------------------------------
Likelihood-ratio test of alpha=0: chibar2(01) =  1.9e+04 Prob>=chibar2 = 0.000

. estimates store DPRE

. display "Table 9.5: third column Sum ln R"
Table 9.5: third column Sum ln R

. lincom LOGR + LOGR1 + LOGR2

 ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 = 0

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .4899344   .0659783     7.43   0.000     .3606192    .6192495
------------------------------------------------------------------------------

. 
. generate PAT_YEAR0 = PAT1 if YEAR==1    // = PAT1 in YEAR 1 and missing in YEARS 1-5
(1384 missing values generated)

. bysort id: egen PAT_INITIAL = mean(PAT_YEAR0)  // Replaces missings with PAT1 in YEAR1

. 
. global XLISTD2 PAT1 LOGR LOGR1 LOGR2 LOGK SCISECT PAT_INITIAL LOGRMEAN LOGR1MEAN LOGR2MEAN dyear2 dyear3 dyear4 dyear5 

. 
. * Correlated random effects versions of the same
. * Cross-section Poisson
. poisson PAT $XLISTD2, vce(cluster id)

Iteration 0:   log pseudolikelihood = -279821.89  
Iteration 1:   log pseudolikelihood = -169670.44  (backed up)
Iteration 2:   log pseudolikelihood = -94501.083  
Iteration 3:   log pseudolikelihood = -18376.372  
Iteration 4:   log pseudolikelihood = -14744.374  
Iteration 5:   log pseudolikelihood = -14580.185  
Iteration 6:   log pseudolikelihood = -14579.679  
Iteration 7:   log pseudolikelihood = -14579.679  

Poisson regression                                Number of obs   =       1730
                                                  Wald chi2(14)   =     764.86
                                                  Prob > chi2     =     0.0000
Log pseudolikelihood = -14579.679                 Pseudo R2       =     0.8063

                                   (Std. Err. adjusted for 346 clusters in id)
------------------------------------------------------------------------------
             |               Robust
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        PAT1 |    .004659   .0013789     3.38   0.001     .0019563    .0073616
        LOGR |   .3680191   .1265515     2.91   0.004     .1199827    .6160554
       LOGR1 |  -.1761849   .1331148    -1.32   0.186    -.4370851    .0847152
       LOGR2 |  -.0392388   .0780056    -0.50   0.615     -.192127    .1136494
        LOGK |   .1720819   .0453834     3.79   0.000     .0831321    .2610317
     SCISECT |   .2719629   .1217646     2.23   0.026     .0333086    .5106172
 PAT_INITIAL |  -.0014259   .0011071    -1.29   0.198    -.0035959     .000744
    LOGRMEAN |   .5861149   1.094472     0.54   0.592    -1.559011    2.731241
   LOGR1MEAN |  -1.556635   1.834338    -0.85   0.396    -5.151871    2.038601
   LOGR2MEAN |   1.178711   .8811638     1.34   0.181    -.5483385     2.90576
      dyear2 |  -.0402669   .0413444    -0.97   0.330    -.1213004    .0407666
      dyear3 |  -.0022761    .038042    -0.06   0.952    -.0768371    .0722849
      dyear4 |  -.1118548   .0457641    -2.44   0.015    -.2015509   -.0221588
      dyear5 |  -.0772369   .0404438    -1.91   0.056    -.1565052    .0020315
       _cons |   1.334279   .2061876     6.47   0.000     .9301587    1.738399
------------------------------------------------------------------------------

. estimates store DPCS2

. * Population averaged Poisson with exchangeable errrors
. xtpoisson PAT $XLISTD2, pa vce(robust)

Iteration 1: tolerance = .63412383
Iteration 2: tolerance = .13295781
Iteration 3: tolerance = .00696397
Iteration 4: tolerance = .00007082
Iteration 5: tolerance = .00006766
Iteration 6: tolerance = 5.306e-06
Iteration 7: tolerance = 7.562e-07

GEE population-averaged model                   Number of obs      =      1730
Group variable:                         id      Number of groups   =       346
Link:                                  log      Obs per group: min =         5
Family:                            Poisson                     avg =       5.0
Correlation:                  exchangeable                     max =         5
                                                Wald chi2(14)      =    544.01
Scale parameter:                         1      Prob > chi2        =    0.0000

                                     (Std. Err. adjusted for clustering on id)
------------------------------------------------------------------------------
             |               Robust
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        PAT1 |   .0013081   .0003492     3.75   0.000     .0006237    .0019925
        LOGR |   .3124704   .0680773     4.59   0.000     .1790413    .4458995
       LOGR1 |  -.1008425   .0717563    -1.41   0.160    -.2414823    .0397973
       LOGR2 |   .0454956   .0597698     0.76   0.447     -.071651    .1626421
        LOGK |   .1770891   .0540251     3.28   0.001     .0712018    .2829764
     SCISECT |   .3222529   .1679943     1.92   0.055    -.0070098    .6515157
 PAT_INITIAL |   .0016659   .0006676     2.50   0.013     .0003575    .0029743
    LOGRMEAN |  -.2157091   1.082218    -0.20   0.842    -2.336817    1.905399
   LOGR1MEAN |   .2100467   1.899797     0.11   0.912    -3.513487     3.93358
   LOGR2MEAN |   .0995838   .9866408     0.10   0.920    -1.834197    2.033364
      dyear2 |  -.0417337    .020654    -2.02   0.043    -.0822148   -.0012526
      dyear3 |  -.0308182   .0244092    -1.26   0.207    -.0786593    .0170229
      dyear4 |  -.1443294   .0349789    -4.13   0.000    -.2128867   -.0757721
      dyear5 |    -.15899   .0333839    -4.76   0.000    -.2244212   -.0935588
       _cons |   1.360092   .2377173     5.72   0.000     .8941745    1.826009
------------------------------------------------------------------------------

. estimates store DPPA2

. 
. * Poisson Random Effects - gamma
. xtpoisson PAT $XLISTD2, re vce(boot, reps($BREPS) seed(10101))
(running xtpoisson on estimation sample)

Bootstrap replications (400)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
..................................................    50
..................................................   100
..................................................   150
..................................................   200
..................................................   250
..................................................   300
..................................................   350
..................................................   400

Random-effects Poisson regression               Number of obs      =      1730
Group variable: id                              Number of groups   =       346

Random effects u_i ~ Gamma                      Obs per group: min =         5
                                                               avg =       5.0
                                                               max =         5

                                                Wald chi2(14)      =   1149.44
Log likelihood  = -5156.4535                    Prob > chi2        =    0.0000

                                    (Replications based on 346 clusters in id)
------------------------------------------------------------------------------
             |   Observed   Bootstrap                         Normal-based
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        PAT1 |   .0012248    .000593     2.07   0.039     .0000626    .0023871
        LOGR |   .3404846   .0871984     3.90   0.000     .1695789    .5113903
       LOGR1 |  -.1040997   .0898571    -1.16   0.247    -.2802164     .072017
       LOGR2 |   .0474496   .0678818     0.70   0.485    -.0855963    .1804955
        LOGK |   .0447689   .0542298     0.83   0.409    -.0615195    .1510574
     SCISECT |  -.0397818   .1126958    -0.35   0.724    -.2606615     .181098
 PAT_INITIAL |   .0044761   .0015915     2.81   0.005     .0013568    .0075955
    LOGRMEAN |  -.1025678   .8831176    -0.12   0.908    -1.833447    1.628311
   LOGR1MEAN |  -.2128072   1.755537    -0.12   0.904    -3.653596    3.227981
   LOGR2MEAN |   .7320889   .9926132     0.74   0.461    -1.213397    2.677575
      dyear2 |  -.0447412   .0215512    -2.08   0.038    -.0869809   -.0025016
      dyear3 |  -.0372623   .0272449    -1.37   0.171    -.0906612    .0161367
      dyear4 |  -.1535682   .0372513    -4.12   0.000    -.2265794    -.080557
      dyear5 |  -.1702754   .0369497    -4.61   0.000    -.2426955   -.0978553
       _cons |    1.03913    .173904     5.98   0.000     .6982845    1.379976
-------------+----------------------------------------------------------------
    /lnalpha |  -.3130783    .090987                     -.4914094   -.1347471
-------------+----------------------------------------------------------------
       alpha |   .7311927    .066529                      .6117636    .8739369
------------------------------------------------------------------------------
Likelihood-ratio test of alpha=0: chibar2(01) =  1.9e+04 Prob>=chibar2 = 0.000

. estimates store DPCCRE

. display "Table 9.6: first column Sum ln R"
Table 9.6: first column Sum ln R

. lincom LOGR + LOGR1 + LOGR2

 ( 1)  [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 = 0

------------------------------------------------------------------------------
         PAT |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .2838345   .0960988     2.95   0.003     .0954843    .4721848
------------------------------------------------------------------------------

. 
. estimates table DPCS DPCS2 DPPA DPPA2 DPRE DPCCRE, b(%7.4f) se(%7.3f) stats(N ll) stfmt(%9.1f) modelwidth(9) equations(1)

--------------------------------------------------------------------------------------
    Variable |   DPCS        DPCS2       DPPA        DPPA2       DPRE       DPCCRE    
-------------+------------------------------------------------------------------------
#1           |
        PAT1 |    0.0034      0.0047      0.0019      0.0013      0.0013      0.0012  
             |     0.001       0.001       0.000       0.000       0.001       0.001  
        LOGR |    0.3591      0.3680      0.3788      0.3125      0.4462      0.3405  
             |     0.144       0.127       0.066       0.068       0.080       0.087  
       LOGR1 |   -0.1593     -0.1762     -0.0802     -0.1008     -0.0595     -0.1041  
             |     0.100       0.133       0.074       0.072       0.090       0.090  
       LOGR2 |    0.1333     -0.0392      0.0778      0.0455      0.1033      0.0474  
             |     0.139       0.078       0.059       0.060       0.066       0.068  
        LOGK |    0.1832      0.1721      0.2229      0.1771      0.3001      0.0448  
             |     0.046       0.045       0.045       0.054       0.055       0.054  
     SCISECT |    0.2888      0.2720      0.3707      0.3223      0.2805     -0.0398  
             |     0.135       0.122       0.156       0.168       0.116       0.113  
      dyear2 |   -0.0424     -0.0403     -0.0439     -0.0417     -0.0464     -0.0447  
             |     0.038       0.041       0.024       0.021       0.022       0.022  
      dyear3 |   -0.0075     -0.0023     -0.0323     -0.0308     -0.0416     -0.0373  
             |     0.037       0.038       0.026       0.024       0.027       0.027  
      dyear4 |   -0.1214     -0.1119     -0.1543     -0.1443     -0.1680     -0.1536  
             |     0.047       0.046       0.038       0.035       0.038       0.037  
      dyear5 |   -0.1105     -0.0772     -0.1694     -0.1590     -0.1964     -0.1703  
             |     0.043       0.040       0.035       0.033       0.036       0.037  
 PAT_INITIAL |               -0.0014                  0.0017                  0.0045  
             |                 0.001                   0.001                   0.002  
    LOGRMEAN |                0.5861                 -0.2157                 -0.1026  
             |                 1.094                   1.082                   0.883  
   LOGR1MEAN |               -1.5566                  0.2100                 -0.2128  
             |                 1.834                   1.900                   1.756  
   LOGR2MEAN |                1.1787                  0.0996                  0.7321  
             |                 0.881                   0.987                   0.993  
       _cons |    1.3300      1.3343      1.1177      1.3601      0.3725      1.0391  
             |     0.210       0.206       0.222       0.238       0.178       0.174  
-------------+------------------------------------------------------------------------
lnalpha      |
       _cons |                                                   -0.1808     -0.3131  
             |                                                     0.095       0.091  
-------------+------------------------------------------------------------------------
Statistics   |                                                                        
           N |      1730        1730        1730        1730        1730        1730  
          ll |  -14717.2    -14579.7                             -5188.0     -5156.5  
--------------------------------------------------------------------------------------
                                                                          legend: b/se

. 
. * Fixed effects GMM using Chamberlain transformation
. * This program is the same as gmm_poipre in Stata manual [r]gmm
. program gmm_poipre
  1.    version 11
  2.    syntax varlist if, at(name) myrhs(varlist) ///
>    mylhs(varlist) myidvar(varlist)
  3.    quietly {
  4.    tempvar mu mubar ybar
  5.    gen double `mu' = 0 `if'
  6.    local j = 1
  7.    foreach var of varlist `myrhs' {
  8.       replace `mu' = `mu' + `var'*`at'[1,`j'] `if'
  9.       local j = `j' + 1
 10.       }
 11.    replace `mu' = exp(`mu')
 12.    replace `varlist' = L.`mylhs' - L.`mu'*`mylhs'/`mu' `if'
 13.    }
 14. end

. 
. * Only include time-varying regressors
. * Also here year 1 is dropped, so drop the year 2 dummy
. * Regressors 
. global XLISTTV PAT1 LOGR LOGR1 LOGR2 dyear3 dyear4 dyear5

. * Instruments in just-identified case
. global IVLISTTV PAT2 LOGR1 LOGR2 LOGR3 dyear3 dyear4 dyear5

. * Instruments in over-identified case
. global IVLISTTV2 PAT2 PAT3 PAT4 LOGR1 LOGR2 LOGR3 dyear3 dyear4 dyear5

. 
. * Just-identified
. gmm gmm_poipre, mylhs(PAT) myrhs($XLISTTV) myidvar(id) nequations(1) ///
>    parameters($XLISTTV) instruments($IVLISTTV, noconstant) onestep vce(cluster id)
warning: 346 missing values returned for equation 1 at initial values

Step 1
Iteration 0:   GMM criterion Q(b) =  9.9319006  
Iteration 1:   GMM criterion Q(b) =  5.1389865  
Iteration 2:   GMM criterion Q(b) =  .39579292  
Iteration 3:   GMM criterion Q(b) =  .00177077  
Iteration 4:   GMM criterion Q(b) =  1.610e-06  
Iteration 5:   GMM criterion Q(b) =  1.158e-12  
Iteration 6:   GMM criterion Q(b) =  6.158e-24  

GMM estimation 

Number of parameters =   7
Number of moments    =   7
Initial weight matrix: Unadjusted                     Number of obs  =    1384

                                   (Std. Err. adjusted for 346 clusters in id)
------------------------------------------------------------------------------
             |               Robust
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       /PAT1 |    .001566   .0017031     0.92   0.358    -.0017721    .0049041
       /LOGR |   1.659566   .5813948     2.85   0.004     .5200527    2.799079
      /LOGR1 |  -.2220653   .1397524    -1.59   0.112     -.495975    .0518444
      /LOGR2 |   .1711975   .0856702     2.00   0.046      .003287    .3391081
     /dyear3 |  -.0245858   .0281413    -0.87   0.382    -.0797416    .0305701
     /dyear4 |  -.2123264   .0521338    -4.07   0.000    -.3145068   -.1101459
     /dyear5 |     -.2947   .0734972    -4.01   0.000    -.4387518   -.1506482
------------------------------------------------------------------------------
Instruments for equation 1: PAT2 LOGR1 LOGR2 LOGR3 dyear3 dyear4 dyear5

. estimates store DPGMM

. 
. * Overidentified
. gmm gmm_poipre, mylhs(PAT) myrhs($XLISTTV) myidvar(id) nequations(1) ///
>   parameters($XLISTTV) instruments($IVLISTTV2, noconstant) twostep vce(cluster id)
warning: 346 missing values returned for equation 1 at initial values

Step 1
Iteration 0:   GMM criterion Q(b) =  14.292883  
Iteration 1:   GMM criterion Q(b) =  5.4360977  
Iteration 2:   GMM criterion Q(b) =  5.3031323  
Iteration 3:   GMM criterion Q(b) =  5.2945936  
Iteration 4:   GMM criterion Q(b) =  5.2924248  
Iteration 5:   GMM criterion Q(b) =  5.2919377  
Iteration 6:   GMM criterion Q(b) =   5.291809  
Iteration 7:   GMM criterion Q(b) =  5.2917771  
Iteration 8:   GMM criterion Q(b) =  5.2917688  
Iteration 9:   GMM criterion Q(b) =  5.2917667  
Iteration 10:  GMM criterion Q(b) =  5.2917662  

Step 2
Iteration 0:   GMM criterion Q(b) =  .00864395  
Iteration 1:   GMM criterion Q(b) =  .00306132  
Iteration 2:   GMM criterion Q(b) =  .00298754  
Iteration 3:   GMM criterion Q(b) =  .00297993  
Iteration 4:   GMM criterion Q(b) =  .00297973  
Iteration 5:   GMM criterion Q(b) =  .00297973  

GMM estimation 

Number of parameters =   7
Number of moments    =   9
Initial weight matrix: Unadjusted                     Number of obs  =    1384
GMM weight matrix:     Cluster (id)

                                   (Std. Err. adjusted for 346 clusters in id)
------------------------------------------------------------------------------
             |               Robust
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       /PAT1 |  -.0001445   .0014953    -0.10   0.923    -.0030753    .0027863
       /LOGR |   .3003946   .7999755     0.38   0.707    -1.267529    1.868318
      /LOGR1 |  -.0681041   .1096623    -0.62   0.535    -.2830383    .1468301
      /LOGR2 |   .1324772   .0775931     1.71   0.088    -.0196025    .2845569
     /dyear3 |   .0093248   .0412341     0.23   0.821    -.0714925     .090142
     /dyear4 |  -.0954911   .0837625    -1.14   0.254    -.2596627    .0686804
     /dyear5 |  -.1432391   .1383765    -1.04   0.301     -.414452    .1279738
------------------------------------------------------------------------------
Instruments for equation 1: PAT2 PAT3 PAT4 LOGR1 LOGR2 LOGR3 dyear3 dyear4 dyear5

. estimates store DPGMMOID

. display "Table 9.6: second column Sum ln R"
Table 9.6: second column Sum ln R

. lincom _b[LOGR:_cons]+_b[LOGR1:_cons]+_b[LOGR2:_cons]

 ( 1)  [LOGR]_cons + [LOGR1]_cons + [LOGR2]_cons = 0

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .3647677   .7956494     0.46   0.647    -1.194676    1.924212
------------------------------------------------------------------------------

. estat overid

  Test of overidentifying restriction:

  Hansen's J chi2(2) = 4.12395 (p = 0.1272)

. predict residGMM

. correlate residGMM L.residGMM L2.residGMM
(obs=692)

             |                 L.      L2.
             | residGMM residGMM residGMM
-------------+---------------------------
    residGMM |
         --. |   1.0000
         L1. |  -0.1736   1.0000
         L2. |   0.0725   0.1071   1.0000


. 
. *** CHECK: THIS DOES POISSON FE USING GMM COMMAND
. 
. * This program is the same as gmm_poi in Stata manual [r]gmm
. program gmm_poi2
  1.    version 11
  2.    syntax varlist if, at(name) myrhs(varlist) ///
>    mylhs(varlist) myidvar(varlist)
  3.    quietly {
  4.    tempvar mu mubar ybar
  5.    gen double `mu' = 0 `if'
  6.    local j = 1
  7.    foreach var of varlist `myrhs' {
  8.       replace `mu' = `mu' + `var'*`at'[1,`j'] `if'
  9.       local j = `j' + 1
 10.       }
 11.    replace `mu' = exp(`mu')
 12.    egen double `mubar' = mean(`mu') `if', by(`myidvar')
 13.    egen double `ybar' = mean(`mylhs') `if', by(`myidvar')
 14.    replace `varlist' = `mylhs' - `mu'*`ybar'/`mubar' `if'
 15.    }
 16. end

. gmm gmm_poi2, mylhs(PAT) myrhs($XLISTTIMEVARYING)          ///
>  myidvar(id) nequations(1) parameters($XLISTTIMEVARYING)   ///
>  instruments($XLISTTIMEVARYING, noconstant) onestep vce(cluster id)

Step 1
Iteration 0:   GMM criterion Q(b) =  2.9813256  
Iteration 1:   GMM criterion Q(b) =  .00139024  
Iteration 2:   GMM criterion Q(b) =  5.343e-10  
Iteration 3:   GMM criterion Q(b) =  1.850e-22  

GMM estimation 

Number of parameters =  10
Number of moments    =  10
Initial weight matrix: Unadjusted                     Number of obs  =    1730

                                   (Std. Err. adjusted for 346 clusters in id)
------------------------------------------------------------------------------
             |               Robust
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       /LOGR |   .3222105   .0807547     3.99   0.000     .1639341    .4804868
      /LOGR1 |  -.0871295   .0712049    -1.22   0.221    -.2266885    .0524295
      /LOGR2 |   .0785816   .0620597     1.27   0.205    -.0430532    .2002164
      /LOGR3 |     .00106    .078183     0.01   0.989    -.1521758    .1542958
      /LOGR4 |  -.0046414    .063583    -0.07   0.942    -.1292617     .119979
      /LOGR5 |   .0026068   .0759235     0.03   0.973    -.1462004    .1514141
     /dyear2 |  -.0426076   .0167407    -2.55   0.011    -.0754187   -.0097965
     /dyear3 |  -.0400462   .0248168    -1.61   0.107    -.0886862    .0085939
     /dyear4 |  -.1571185    .035894    -4.38   0.000    -.2274694   -.0867676
     /dyear5 |  -.1980306   .0368759    -5.37   0.000    -.2703059   -.1257552
------------------------------------------------------------------------------
Instruments for equation 1: LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5

. estimates store PFEGMM

.  
. ************** CROSS-SECTION SUMMARY
. 
. estimates table PCSdef PCSrob PCSclu NBCSdef NBCSrob NBCSclu, b(%7.4f) se(%7.3f) stats(N ll) stfmt(%9.1f) modelwidth(9)  

--------------------------------------------------------------------------------------
    Variable |  PCSdef      PCSrob      PCSclu      NBCSdef     NBCSrob     NBCSclu   
-------------+------------------------------------------------------------------------
PAT          |
        LOGR |    0.1345      0.1345      0.1345      0.4311      0.4311      0.4311  
             |     0.031       0.180       0.183       0.112       0.141       0.133  
       LOGR1 |   -0.0529     -0.0529     -0.0529     -0.1171     -0.1171     -0.1171  
             |     0.043       0.242       0.106       0.156       0.186       0.141  
       LOGR2 |    0.0082      0.0082      0.0082      0.1065      0.1065      0.1065  
             |     0.040       0.232       0.093       0.150       0.168       0.121  
       LOGR3 |    0.0661      0.0661      0.0661      0.0764      0.0764      0.0764  
             |     0.037       0.221       0.114       0.137       0.155       0.103  
       LOGR4 |    0.0902      0.0902      0.0902      0.1938      0.1938      0.1938  
             |     0.033       0.198       0.093       0.125       0.128       0.088  
       LOGR5 |    0.2395      0.2395      0.2395      0.1194      0.1194      0.1194  
             |     0.022       0.132       0.123       0.085       0.090       0.086  
        LOGK |    0.2529      0.2529      0.2529      0.1013      0.1013      0.1013  
             |     0.004       0.028       0.059       0.024       0.027       0.054  
     SCISECT |    0.4543      0.4543      0.4543     -0.0046     -0.0046     -0.0046  
             |     0.009       0.077       0.167       0.056       0.059       0.119  
      dyear2 |   -0.0435     -0.0435     -0.0435     -0.0558     -0.0558     -0.0558  
             |     0.013       0.096       0.018       0.077       0.076       0.035  
      dyear3 |   -0.0524     -0.0524     -0.0524     -0.0609     -0.0609     -0.0609  
             |     0.013       0.097       0.030       0.077       0.080       0.043  
      dyear4 |   -0.1702     -0.1702     -0.1702     -0.1220     -0.1220     -0.1220  
             |     0.014       0.094       0.046       0.077       0.085       0.047  
      dyear5 |   -0.2019     -0.2019     -0.2019     -0.2267     -0.2267     -0.2267  
             |     0.014       0.089       0.046       0.077       0.085       0.049  
       _cons |    0.8099      0.8099      0.8099      0.9088      0.9088      0.9088  
             |     0.021       0.130       0.242       0.097       0.105       0.182  
-------------+------------------------------------------------------------------------
lnalpha      |
       _cons |                                       -0.2660     -0.2660     -0.2660  
             |                                         0.044       0.048       0.089  
-------------+------------------------------------------------------------------------
Statistics   |                                                                        
           N |      1730        1730        1730        1730        1730        1730  
          ll |  -17834.1    -17834.1    -17834.1     -5773.4     -5773.4     -5773.4  
--------------------------------------------------------------------------------------
                                                                          legend: b/se

. 
. ************** POPULATION AVERAGED SUMMARY
. 
. estimates table PPAEXdef PPAEXrob PPAARrob NBPAEXdef NBPAEXrob NBPAARrob, b(%7.4f) se(%7.3f) stats(N ll) stfmt(%9.1f) modelwi
> dth(9)

--------------------------------------------------------------------------------------
    Variable | PPAEXdef    PPAEXrob    PPAARrob    NBPAEXdef   NBPAEXrob   NBPAARrob  
-------------+------------------------------------------------------------------------
        LOGR |    0.3156      0.3156      0.2573      0.5204      0.5204      0.4628  
             |     0.014       0.062       0.056       0.079       0.108       0.106  
       LOGR1 |   -0.0522     -0.0522     -0.0280     -0.0848     -0.0848     -0.0573  
             |     0.016       0.060       0.058       0.093       0.113       0.105  
       LOGR2 |    0.1048      0.1048      0.1201      0.1249      0.1249      0.1466  
             |     0.014       0.054       0.058       0.087       0.085       0.096  
       LOGR3 |    0.0197      0.0197      0.0459      0.0534      0.0534      0.0759  
             |     0.013       0.067       0.060       0.081       0.099       0.103  
       LOGR4 |    0.0230      0.0230      0.0537      0.0914      0.0914      0.1448  
             |     0.012       0.054       0.050       0.074       0.083       0.074  
       LOGR5 |    0.0489      0.0489      0.0268      0.0236      0.0236      0.0142  
             |     0.010       0.055       0.046       0.057       0.061       0.064  
        LOGK |    0.2699      0.2699      0.2623      0.1635      0.1635      0.1191  
             |     0.008       0.057       0.054       0.041       0.047       0.049  
     SCISECT |    0.4402      0.4402      0.4708      0.0687      0.0687      0.0114  
             |     0.019       0.175       0.170       0.105       0.114       0.115  
      dyear2 |   -0.0456     -0.0456     -0.0453     -0.0536     -0.0536     -0.0535  
             |     0.005       0.017       0.017       0.045       0.034       0.034  
      dyear3 |   -0.0462     -0.0462     -0.0447     -0.0575     -0.0575     -0.0547  
             |     0.005       0.026       0.026       0.045       0.040       0.042  
      dyear4 |   -0.1686     -0.1686     -0.1633     -0.1237     -0.1237     -0.1148  
             |     0.005       0.041       0.042       0.045       0.046       0.048  
      dyear5 |   -0.2136     -0.2136     -0.2053     -0.2393     -0.2393     -0.2302  
             |     0.005       0.041       0.041       0.045       0.049       0.052  
       _cons |    0.7774      0.7774      0.7498      0.7333      0.7333      0.8553  
             |     0.039       0.245       0.234       0.156       0.169       0.175  
-------------+------------------------------------------------------------------------
           N |      1730        1730        1730        1730        1730        1730  
          ll |                                                                        
--------------------------------------------------------------------------------------
                                                                          legend: b/se

. 
. * estimates table PCSdef PCSrob PCSclu PAdef PArob, b(%7.4f) se stats(N ll) star(0.05, 0.01, 0.001) equations(1) stfmt(%9.1f)
>  modelwidth(9)
. 
. ************** FIXED EFFECTS SUMMARY
. 
. estimates table PFEdef PFErob NBFEdef, b(%7.4f) se stats(N ll) equations(1) stfmt(%9.1f) modelwidth(9)

--------------------------------------------------
    Variable |  PFEdef      PFErob      NBFEdef   
-------------+------------------------------------
        LOGR |    0.3222      0.3222      0.2727  
             |    0.0459      0.0808      0.0708  
       LOGR1 |   -0.0871     -0.0871     -0.0979  
             |    0.0487      0.0712      0.0768  
       LOGR2 |    0.0786      0.0786      0.0321  
             |    0.0448      0.0621      0.0709  
       LOGR3 |    0.0011      0.0011     -0.0204  
             |    0.0414      0.0782      0.0658  
       LOGR4 |   -0.0046     -0.0046      0.0162  
             |    0.0378      0.0636      0.0629  
       LOGR5 |    0.0026      0.0026     -0.0097  
             |    0.0323      0.0759      0.0533  
      dyear2 |   -0.0426     -0.0426     -0.0384  
             |    0.0131      0.0167      0.0245  
      dyear3 |   -0.0400     -0.0400     -0.0399  
             |    0.0135      0.0248      0.0252  
      dyear4 |   -0.1571     -0.1571     -0.1443  
             |    0.0142      0.0359      0.0265  
      dyear5 |   -0.1980     -0.1980     -0.1958  
             |    0.0153      0.0369      0.0272  
        LOGK |                            0.2071  
             |                            0.0780  
     SCISECT |                            0.0176  
             |                            0.1981  
       _cons |                            1.6614  
             |                            0.3436  
-------------+------------------------------------
           N |      1620        1620        1620  
          ll |   -3536.3     -3536.3     -3203.1  
--------------------------------------------------
                                      legend: b/se

. 
. ************** RANDOM EFFECTS SUMMARY
. 
. estimates table PREdef PRErob PRENdef NBREdef NBRErob, b(%7.4f) se(%7.3f) stats(N ll) stfmt(%9.1f) modelwidth(9)

--------------------------------------------------------------------------
    Variable |  PREdef      PRErob      PRENdef     NBREdef     NBRErob   
-------------+------------------------------------------------------------
PAT          |
        LOGR |    0.4035      0.4035      0.4153      0.3503      0.3503  
             |     0.044       0.081       0.044       0.065       0.072  
       LOGR1 |   -0.0462     -0.0462     -0.0403     -0.0030     -0.0030  
             |     0.048       0.077       0.048       0.075       0.072  
       LOGR2 |    0.1079      0.1079      0.1121      0.1050      0.1050  
             |     0.045       0.064       0.045       0.069       0.058  
       LOGR3 |    0.0298      0.0298      0.0348      0.0164      0.0164  
             |     0.041       0.084       0.041       0.064       0.077  
       LOGR4 |    0.0107      0.0107      0.0127      0.0359      0.0359  
             |     0.038       0.067       0.038       0.059       0.059  
       LOGR5 |    0.0406      0.0406      0.0471      0.0718      0.0718  
             |     0.032       0.076       0.032       0.048       0.061  
        LOGK |    0.2917      0.2917      0.2917      0.1619      0.1619  
             |     0.039       0.077       0.042       0.042       0.054  
     SCISECT |    0.2570      0.2570      0.4435      0.1176      0.1176  
             |     0.112       0.136       0.124       0.107       0.139  
      dyear2 |   -0.0450     -0.0450     -0.0453     -0.0437     -0.0437  
             |     0.013       0.018       0.013       0.021       0.017  
      dyear3 |   -0.0484     -0.0484     -0.0497     -0.0557     -0.0557  
             |     0.013       0.027       0.013       0.022       0.026  
      dyear4 |   -0.1742     -0.1742     -0.1767     -0.1831     -0.1831  
             |     0.014       0.039       0.014       0.023       0.036  
      dyear5 |   -0.2259     -0.2259     -0.2301     -0.2300     -0.2300  
             |     0.015       0.039       0.015       0.023       0.036  
       _cons |    0.4108      0.4108     -0.1513      0.8996      0.8996  
             |     0.147       0.226       0.169       0.168       0.215  
-------------+------------------------------------------------------------
lnalpha      |
       _cons |   -0.1567     -0.1567                                      
             |     0.081       0.099                                      
-------------+------------------------------------------------------------
lnsig2u      |
       _cons |                           -0.0053                          
             |                             0.095                          
-------------+------------------------------------------------------------
ln_r         |
       _cons |                                        0.9878      0.9878  
             |                                         0.096       0.162  
-------------+------------------------------------------------------------
ln_s         |
       _cons |                                        0.7010      0.7010  
             |                                         0.108       0.130  
-------------+------------------------------------------------------------
Statistics   |                                                            
           N |      1730        1730        1730        1730        1730  
          ll |   -5234.9     -5234.9     -5245.0     -4948.5     -4948.5  
--------------------------------------------------------------------------
                                                              legend: b/se

. 
. ************** COMBINED RESULTS SUMMARY
. 
. * Poisson
. estimates table PCSclu PPAEXrob PRErob PFErob, b(%7.4f) se(%7.3f) stats(N ll) equations(1) stfmt(%9.1f) modelwidth(9)

--------------------------------------------------------------
    Variable |  PCSclu     PPAEXrob     PRErob      PFErob    
-------------+------------------------------------------------
#1           |
        LOGR |    0.1345      0.3156      0.4035      0.3222  
             |     0.183       0.062       0.081       0.081  
       LOGR1 |   -0.0529     -0.0522     -0.0462     -0.0871  
             |     0.106       0.060       0.077       0.071  
       LOGR2 |    0.0082      0.1048      0.1079      0.0786  
             |     0.093       0.054       0.064       0.062  
       LOGR3 |    0.0661      0.0197      0.0298      0.0011  
             |     0.114       0.067       0.084       0.078  
       LOGR4 |    0.0902      0.0230      0.0107     -0.0046  
             |     0.093       0.054       0.067       0.064  
       LOGR5 |    0.2395      0.0489      0.0406      0.0026  
             |     0.123       0.055       0.076       0.076  
        LOGK |    0.2529      0.2699      0.2917              
             |     0.059       0.057       0.077              
     SCISECT |    0.4543      0.4402      0.2570              
             |     0.167       0.175       0.136              
      dyear2 |   -0.0435     -0.0456     -0.0450     -0.0426  
             |     0.018       0.017       0.018       0.017  
      dyear3 |   -0.0524     -0.0462     -0.0484     -0.0400  
             |     0.030       0.026       0.027       0.025  
      dyear4 |   -0.1702     -0.1686     -0.1742     -0.1571  
             |     0.046       0.041       0.039       0.036  
      dyear5 |   -0.2019     -0.2136     -0.2259     -0.1980  
             |     0.046       0.041       0.039       0.037  
       _cons |    0.8099      0.7774      0.4108              
             |     0.242       0.245       0.226              
-------------+------------------------------------------------
lnalpha      |
       _cons |                           -0.1567              
             |                             0.099              
-------------+------------------------------------------------
Statistics   |                                                
           N |      1730        1730        1730        1620  
          ll |  -17834.1                 -5234.9     -3536.3  
--------------------------------------------------------------
                                                  legend: b/se

. 
. * Negative binomial
. estimates table NBCSclu NBPAEXrob NBRErob NBFEdef, b(%7.4f) se(%7.3f) stats(N ll) equations(1) stfmt(%9.1f) modelwidth(9)

--------------------------------------------------------------
    Variable |  NBCSclu    NBPAEXrob    NBRErob     NBFEdef   
-------------+------------------------------------------------
#1           |
        LOGR |    0.4311      0.5204      0.3503      0.2727  
             |     0.133       0.108       0.072       0.071  
       LOGR1 |   -0.1171     -0.0848     -0.0030     -0.0979  
             |     0.141       0.113       0.072       0.077  
       LOGR2 |    0.1065      0.1249      0.1050      0.0321  
             |     0.121       0.085       0.058       0.071  
       LOGR3 |    0.0764      0.0534      0.0164     -0.0204  
             |     0.103       0.099       0.077       0.066  
       LOGR4 |    0.1938      0.0914      0.0359      0.0162  
             |     0.088       0.083       0.059       0.063  
       LOGR5 |    0.1194      0.0236      0.0718     -0.0097  
             |     0.086       0.061       0.061       0.053  
        LOGK |    0.1013      0.1635      0.1619      0.2071  
             |     0.054       0.047       0.054       0.078  
     SCISECT |   -0.0046      0.0687      0.1176      0.0176  
             |     0.119       0.114       0.139       0.198  
      dyear2 |   -0.0558     -0.0536     -0.0437     -0.0384  
             |     0.035       0.034       0.017       0.024  
      dyear3 |   -0.0609     -0.0575     -0.0557     -0.0399  
             |     0.043       0.040       0.026       0.025  
      dyear4 |   -0.1220     -0.1237     -0.1831     -0.1443  
             |     0.047       0.046       0.036       0.026  
      dyear5 |   -0.2267     -0.2393     -0.2300     -0.1958  
             |     0.049       0.049       0.036       0.027  
       _cons |    0.9088      0.7333      0.8996      1.6614  
             |     0.182       0.169       0.215       0.344  
-------------+------------------------------------------------
lnalpha      |
       _cons |   -0.2660                                      
             |     0.089                                      
-------------+------------------------------------------------
ln_r         |
       _cons |                            0.9878              
             |                             0.162              
-------------+------------------------------------------------
ln_s         |
       _cons |                            0.7010              
             |                             0.130              
-------------+------------------------------------------------
Statistics   |                                                
           N |      1730        1730        1730        1620  
          ll |   -5773.4                 -4948.5     -3203.1  
--------------------------------------------------------------
                                                  legend: b/se

. 
. * Poisson versus negative binomial 1
. estimates table PCSclu NBCSclu PPAEXrob NBPAEXrob, b(%7.4f) se(%7.3f) stats(N ll) equations(1) stfmt(%9.1f) modelwidth(9)

--------------------------------------------------------------
    Variable |  PCSclu      NBCSclu    PPAEXrob    NBPAEXrob  
-------------+------------------------------------------------
#1           |
        LOGR |    0.1345      0.4311      0.3156      0.5204  
             |     0.183       0.133       0.062       0.108  
       LOGR1 |   -0.0529     -0.1171     -0.0522     -0.0848  
             |     0.106       0.141       0.060       0.113  
       LOGR2 |    0.0082      0.1065      0.1048      0.1249  
             |     0.093       0.121       0.054       0.085  
       LOGR3 |    0.0661      0.0764      0.0197      0.0534  
             |     0.114       0.103       0.067       0.099  
       LOGR4 |    0.0902      0.1938      0.0230      0.0914  
             |     0.093       0.088       0.054       0.083  
       LOGR5 |    0.2395      0.1194      0.0489      0.0236  
             |     0.123       0.086       0.055       0.061  
        LOGK |    0.2529      0.1013      0.2699      0.1635  
             |     0.059       0.054       0.057       0.047  
     SCISECT |    0.4543     -0.0046      0.4402      0.0687  
             |     0.167       0.119       0.175       0.114  
      dyear2 |   -0.0435     -0.0558     -0.0456     -0.0536  
             |     0.018       0.035       0.017       0.034  
      dyear3 |   -0.0524     -0.0609     -0.0462     -0.0575  
             |     0.030       0.043       0.026       0.040  
      dyear4 |   -0.1702     -0.1220     -0.1686     -0.1237  
             |     0.046       0.047       0.041       0.046  
      dyear5 |   -0.2019     -0.2267     -0.2136     -0.2393  
             |     0.046       0.049       0.041       0.049  
       _cons |    0.8099      0.9088      0.7774      0.7333  
             |     0.242       0.182       0.245       0.169  
-------------+------------------------------------------------
lnalpha      |
       _cons |               -0.2660                          
             |                 0.089                          
-------------+------------------------------------------------
Statistics   |                                                
           N |      1730        1730        1730        1730  
          ll |  -17834.1     -5773.4                          
--------------------------------------------------------------
                                                  legend: b/se

. 
. * Poisson versus negative binomial 2
. estimates table PRErob NBRErob PFEdef NBFEdef, b(%7.4f) se(%7.3f) stats(N ll) equations(1) stfmt(%9.1f) modelwidth(9)

--------------------------------------------------------------
    Variable |  PRErob      NBRErob     PFEdef      NBFEdef   
-------------+------------------------------------------------
#1           |
        LOGR |    0.4035      0.3503      0.3222      0.2727  
             |     0.081       0.072       0.046       0.071  
       LOGR1 |   -0.0462     -0.0030     -0.0871     -0.0979  
             |     0.077       0.072       0.049       0.077  
       LOGR2 |    0.1079      0.1050      0.0786      0.0321  
             |     0.064       0.058       0.045       0.071  
       LOGR3 |    0.0298      0.0164      0.0011     -0.0204  
             |     0.084       0.077       0.041       0.066  
       LOGR4 |    0.0107      0.0359     -0.0046      0.0162  
             |     0.067       0.059       0.038       0.063  
       LOGR5 |    0.0406      0.0718      0.0026     -0.0097  
             |     0.076       0.061       0.032       0.053  
        LOGK |    0.2917      0.1619                  0.2071  
             |     0.077       0.054                   0.078  
     SCISECT |    0.2570      0.1176                  0.0176  
             |     0.136       0.139                   0.198  
      dyear2 |   -0.0450     -0.0437     -0.0426     -0.0384  
             |     0.018       0.017       0.013       0.024  
      dyear3 |   -0.0484     -0.0557     -0.0400     -0.0399  
             |     0.027       0.026       0.013       0.025  
      dyear4 |   -0.1742     -0.1831     -0.1571     -0.1443  
             |     0.039       0.036       0.014       0.026  
      dyear5 |   -0.2259     -0.2300     -0.1980     -0.1958  
             |     0.039       0.036       0.015       0.027  
       _cons |    0.4108      0.8996                  1.6614  
             |     0.226       0.215                   0.344  
-------------+------------------------------------------------
lnalpha      |
       _cons |   -0.1567                                      
             |     0.099                                      
-------------+------------------------------------------------
ln_r         |
       _cons |                0.9878                          
             |                 0.162                          
-------------+------------------------------------------------
ln_s         |
       _cons |                0.7010                          
             |                 0.130                          
-------------+------------------------------------------------
Statistics   |                                                
           N |      1730        1730        1620        1620  
          ll |   -5234.9     -4948.5     -3536.3     -3203.1  
--------------------------------------------------------------
                                                  legend: b/se

. 
. ************** TABLES in the BOOK
. 
. *** TABLE 9.2: POOLED POISSON, POOLED GEE, POISSON FE, NB1 FE
. * Note: Following gives default se's for NB1FE and not jackknife se's (given above)
. estimates table PCSclu PPAEXrob PFErob NBFEdef, b(%7.4f) se(%7.3f) stats(N ll) stfmt(%9.1f) modelwidth(9) equations(1)

--------------------------------------------------------------
    Variable |  PCSclu     PPAEXrob     PFErob      NBFEdef   
-------------+------------------------------------------------
        LOGR |    0.1345      0.3156      0.3222      0.2727  
             |     0.183       0.062       0.081       0.071  
       LOGR1 |   -0.0529     -0.0522     -0.0871     -0.0979  
             |     0.106       0.060       0.071       0.077  
       LOGR2 |    0.0082      0.1048      0.0786      0.0321  
             |     0.093       0.054       0.062       0.071  
       LOGR3 |    0.0661      0.0197      0.0011     -0.0204  
             |     0.114       0.067       0.078       0.066  
       LOGR4 |    0.0902      0.0230     -0.0046      0.0162  
             |     0.093       0.054       0.064       0.063  
       LOGR5 |    0.2395      0.0489      0.0026     -0.0097  
             |     0.123       0.055       0.076       0.053  
        LOGK |    0.2529      0.2699                  0.2071  
             |     0.059       0.057                   0.078  
     SCISECT |    0.4543      0.4402                  0.0176  
             |     0.167       0.175                   0.198  
      dyear2 |   -0.0435     -0.0456     -0.0426     -0.0384  
             |     0.018       0.017       0.017       0.024  
      dyear3 |   -0.0524     -0.0462     -0.0400     -0.0399  
             |     0.030       0.026       0.025       0.025  
      dyear4 |   -0.1702     -0.1686     -0.1571     -0.1443  
             |     0.046       0.041       0.036       0.026  
      dyear5 |   -0.2019     -0.2136     -0.1980     -0.1958  
             |     0.046       0.041       0.037       0.027  
       _cons |    0.8099      0.7774                  1.6614  
             |     0.242       0.245                   0.344  
-------------+------------------------------------------------
           N |      1730        1730        1620        1620  
          ll |  -17834.1                 -3536.3     -3203.1  
--------------------------------------------------------------
                                                  legend: b/se

. 
. *** TABLE 9.3: RANDOM EFFECTS - Poisson-gamma, Poisson-normal, NB, CCRE
. * For Poisson RE - normal default se's given here to speed up program (jackknife given above)
. estimates table PRErob PRENdef NBRErob PCCRErob, b(%7.4f) se(%7.3f) stats(N ll) stfmt(%9.1f) modelwidth(9) equations(1)

--------------------------------------------------------------
    Variable |  PRErob      PRENdef     NBRErob    PCCRErob   
-------------+------------------------------------------------
#1           |
        LOGR |    0.4035      0.4153      0.3503      0.3217  
             |     0.081       0.044       0.072       0.089  
       LOGR1 |   -0.0462     -0.0403     -0.0030     -0.0871  
             |     0.077       0.048       0.072       0.076  
       LOGR2 |    0.1079      0.1121      0.1050      0.0789  
             |     0.064       0.045       0.058       0.065  
       LOGR3 |    0.0298      0.0348      0.0164      0.0004  
             |     0.084       0.041       0.077       0.082  
       LOGR4 |    0.0107      0.0127      0.0359     -0.0048  
             |     0.067       0.038       0.059       0.069  
       LOGR5 |    0.0406      0.0471      0.0718      0.0024  
             |     0.076       0.032       0.061       0.080  
        LOGK |    0.2917      0.2917      0.1619      0.0617  
             |     0.077       0.042       0.054       0.060  
     SCISECT |    0.2570      0.4435      0.1176     -0.0490  
             |     0.136       0.124       0.139       0.121  
      dyear2 |   -0.0450     -0.0453     -0.0437     -0.0426  
             |     0.018       0.013       0.017       0.018  
      dyear3 |   -0.0484     -0.0497     -0.0557     -0.0400  
             |     0.027       0.013       0.026       0.027  
      dyear4 |   -0.1742     -0.1767     -0.1831     -0.1570  
             |     0.039       0.014       0.036       0.037  
      dyear5 |   -0.2259     -0.2301     -0.2300     -0.1979  
             |     0.039       0.015       0.036       0.040  
    LOGRMEAN |                                        0.1288  
             |                                         0.892  
   LOGR1MEAN |                                        0.3373  
             |                                         1.909  
   LOGR2MEAN |                                       -1.0581  
             |                                         2.153  
   LOGR3MEAN |                                        0.4736  
             |                                         1.778  
   LOGR4MEAN |                                        0.8514  
             |                                         1.306  
   LOGR5MEAN |                                       -0.1953  
             |                                         0.579  
       _cons |    0.4108     -0.1513      0.8996      1.0384  
             |     0.226       0.169       0.215       0.196  
-------------+------------------------------------------------
lnalpha      |
       _cons |   -0.1567                             -0.2324  
             |     0.099                               0.087  
-------------+------------------------------------------------
lnsig2u      |
       _cons |               -0.0053                          
             |                 0.095                          
-------------+------------------------------------------------
ln_r         |
       _cons |                            0.9878              
             |                             0.162              
-------------+------------------------------------------------
ln_s         |
       _cons |                            0.7010              
             |                             0.130              
-------------+------------------------------------------------
Statistics   |                                                
           N |      1730        1730        1730        1730  
          ll |   -5234.9     -5245.0     -4948.5     -5211.9  
--------------------------------------------------------------
                                                  legend: b/se

. 
. *** TABLE 9.5 and first column TABLE 9.6: DYNAMIC MODELS RANDOM EFFECTS AND CCRE
. estimates table DPCS DPPA DPRE DPCCRE, b(%7.4f) se(%7.3f) stats(N ll) stfmt(%9.1f) modelwidth(9) equations(1)

--------------------------------------------------------------
    Variable |   DPCS        DPPA        DPRE       DPCCRE    
-------------+------------------------------------------------
#1           |
        PAT1 |    0.0034      0.0019      0.0013      0.0012  
             |     0.001       0.000       0.001       0.001  
        LOGR |    0.3591      0.3788      0.4462      0.3405  
             |     0.144       0.066       0.080       0.087  
       LOGR1 |   -0.1593     -0.0802     -0.0595     -0.1041  
             |     0.100       0.074       0.090       0.090  
       LOGR2 |    0.1333      0.0778      0.1033      0.0474  
             |     0.139       0.059       0.066       0.068  
        LOGK |    0.1832      0.2229      0.3001      0.0448  
             |     0.046       0.045       0.055       0.054  
     SCISECT |    0.2888      0.3707      0.2805     -0.0398  
             |     0.135       0.156       0.116       0.113  
      dyear2 |   -0.0424     -0.0439     -0.0464     -0.0447  
             |     0.038       0.024       0.022       0.022  
      dyear3 |   -0.0075     -0.0323     -0.0416     -0.0373  
             |     0.037       0.026       0.027       0.027  
      dyear4 |   -0.1214     -0.1543     -0.1680     -0.1536  
             |     0.047       0.038       0.038       0.037  
      dyear5 |   -0.1105     -0.1694     -0.1964     -0.1703  
             |     0.043       0.035       0.036       0.037  
 PAT_INITIAL |                                        0.0045  
             |                                         0.002  
    LOGRMEAN |                                       -0.1026  
             |                                         0.883  
   LOGR1MEAN |                                       -0.2128  
             |                                         1.756  
   LOGR2MEAN |                                        0.7321  
             |                                         0.993  
       _cons |    1.3300      1.1177      0.3725      1.0391  
             |     0.210       0.222       0.178       0.174  
-------------+------------------------------------------------
lnalpha      |
       _cons |                           -0.1808     -0.3131  
             |                             0.095       0.091  
-------------+------------------------------------------------
Statistics   |                                                
           N |      1730        1730        1730        1730  
          ll |  -14717.2                 -5188.0     -5156.5  
--------------------------------------------------------------
                                                  legend: b/se

. 
. *** TABLE 9.6: DYNAMIC MODELS FIXED EFFECTS 
. * Second column as first column given with TABLE 9.5 results 
. estimates table DPGMMOID, b(%7.4f) se(%7.3f) stats(N ll) stfmt(%9.1f) modelwidth(9)

--------------------------
    Variable | DPGMMOID   
-------------+------------
PAT1         |
       _cons |   -0.0001  
             |     0.001  
-------------+------------
LOGR         |
       _cons |    0.3004  
             |     0.800  
-------------+------------
LOGR1        |
       _cons |   -0.0681  
             |     0.110  
-------------+------------
LOGR2        |
       _cons |    0.1325  
             |     0.078  
-------------+------------
dyear3       |
       _cons |    0.0093  
             |     0.041  
-------------+------------
dyear4       |
       _cons |   -0.0955  
             |     0.084  
-------------+------------
dyear5       |
       _cons |   -0.1432  
             |     0.138  
-------------+------------
Statistics   |            
           N |      1384  
          ll |            
--------------------------
              legend: b/se

. 
. ********** CLOSE OUTPUT
. 
. * log close
. * clear
. * exit
. 
end of do-file

. exit, clear
