-------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  c:\acdbookrevision\stata_final_programs_2013\racd07.txt
  log type:  text
 opened on:  18 Jan 2013, 09:48:20

. 
. ********** OVERVIEW OF racd07.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 program does the analysis for chapter 7
. *  7.3    STATIC REGRESSION AND AUTOCORRELATIONS FOR STRIKES DATA
. *  7.11.1 DYNAMIC REGRESSION FOR STRIKES DATA
. *  7.11.2 DYNAMIC REGRESSION FOR STOCK TRADES DATA
. 
. * To run you need files
. *   racd07data1strikes.dta
. *   racd07data2stocktrades.dta
. * in your directory
. 
. * And you need Stata user-written command
. *   countfit
. 
. ********** SETUP **********
. 
. set more off

. version 12

. clear all

. set linesize 82

. set scheme s1mono  // Graphics scheme

. 
. ********** DATA DESCRIPTION
. 
. * The original data in racd07data1strikes.dta are from 
. *   J. Kennan, "The Duration of Contract strikes in U.S. Manufacturing",
. *   Journal of Econometrics, 1985, Vol. 28, pp.5-28.
. * The data are also used in 
. * A.C. Cameron and P.K. Trivedi (1990), 
. * "Regression based tests for overdispersion", 
. * Journal of Econometrics, Vol. 46, pp. 347-364.
. * For more details see these articles and racd07makedata1strikes.do
. 
. * The original data in racd07data2stocktrades.dta are from 
. * R.C. Jung, R. Liesenfeld and J.-F. Richard (2011)
. * "Dynamic Factor Models for Multivariate Count Data: An Application to 
. *  Stock-Market Trading Activity," JBES, 29, 73-85.
. * Data are the number of trades on the NYSE in 5 minute intervals
. * for Geltfelter Company (GLT) over 39 trading days Jan 3 - Feb 18 2005
. * There are 75 5-minute intervals times 39 days   
. * For more details racd07makedata2stocktrades.do
. 
. ********** 7.3 STATIC REGRESSION AND AUTOCORRELATIONS: STRIKES DATA 
. 
. use racd07data1strikes.dta, clear

. 
. *** TABLE 7.1: VARIABLE DEFINITIONS AND SUMMARY STATISTICS
. 
. summarize

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     STRIKES |       108    5.240741    3.751312          0         18
      OUTPUT |       108   -.0036954    .0545578    -.13996     .08554
       MONTH |       108        54.5    31.32092          1        108

. describe 

Contains data from racd07data1strikes.dta
  obs:           108                          
 vars:             3                          21 Jul 2011 10:36
 size:         1,296                          
----------------------------------------------------------------------------------
              storage  display     value
variable name   type   format      label      variable label
----------------------------------------------------------------------------------
STRIKES         float  %9.0g                  Number of strikes commenced each
                                                month
OUTPUT          float  %9.0g                  Deviation of monthly industrial
                                                production from its trend level
MONTH           float  %9.0g                  Month: 1968(1) to 1976(12)
----------------------------------------------------------------------------------
Sorted by:  MONTH

. tabulate STRIKES

  Number of |
    strikes |
  commenced |
 each month |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          5        4.63        4.63
          1 |         12       11.11       15.74
          2 |         14       12.96       28.70
          3 |         11       10.19       38.89
          4 |          9        8.33       47.22
          5 |         14       12.96       60.19
          6 |          9        8.33       68.52
          7 |          4        3.70       72.22
          8 |          7        6.48       78.70
          9 |         10        9.26       87.96
         10 |          6        5.56       93.52
         11 |          1        0.93       94.44
         13 |          3        2.78       97.22
         15 |          1        0.93       98.15
         16 |          1        0.93       99.07
         18 |          1        0.93      100.00
------------+-----------------------------------
      Total |        108      100.00

. 
. *** FIGURE 7.1: STRIKES AND OUTPUT OVER TIMES
. 
. graph twoway (line STRIKES MONTH, lwidth(medthick))                       ///
>   (line OUTPUT MONTH, lpattern(dash) lwidth(medthick) yaxis(2)),         ///
>   scale(1.2) yscale(range(0 20) axis(1)) yscale(range(-0.1 0.15) axis(2)) ///
>   legend(ring(0) rows(2) pos(12) label(1 "Strikes")          ///
>   label(2 "Output")) ytitle("Strikes", axis(1)) ytitle("Output", axis(2)) 

. graph export racd07fig1.eps, replace
(file racd07fig1.eps written in EPS format)

. graph export racd07fig1.wmf, replace
(file c:\acdbookrevision\stata_final_programs_2013\racd07fig1.wmf written in Windo
> ws Metafile format)

. 
. * Poisson QMLE with various standard errors
. * Stock and Watson text suggests #lags = 0.75*T^(1/3) (= 3.57 here)
. * Optimal for linear AR(1) y and error with rho=0.5
. * based on Andrews (1991, eq.5.3)
. glm STRIKES OUTPUT, family(poisson) vce(robust)

Iteration 0:   log pseudolikelihood = -313.12939  
Iteration 1:   log pseudolikelihood = -311.98566  
Iteration 2:   log pseudolikelihood = -311.98445  
Iteration 3:   log pseudolikelihood = -311.98445  

Generalized linear models                          No. of obs      =       108
Optimization     : ML                              Residual df     =       106
                                                   Scale parameter =         1
Deviance         =  279.7405364                    (1/df) Deviance =  2.639062
Pearson          =  262.5029208                    (1/df) Pearson  =  2.476443

Variance function: V(u) = u                        [Poisson]
Link function    : g(u) = ln(u)                    [Log]

                                                   AIC             =  5.814527
Log pseudolikelihood = -311.9844508                BIC             = -216.5654

------------------------------------------------------------------------------
             |               Robust
     STRIKES |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      OUTPUT |   3.134217    1.18364     2.65   0.008     .8143251    5.454109
       _cons |   1.653893   .0659347    25.08   0.000     1.524663    1.783123
------------------------------------------------------------------------------

. estimates store HAC0 

. glm STRIKES OUTPUT, family(poisson) vce(hac nwest 4)

Iteration 0:   log likelihood = -313.12939  
Iteration 1:   log likelihood = -311.98566  
Iteration 2:   log likelihood = -311.98445  
Iteration 3:   log likelihood = -311.98445  

Generalized linear models                          No. of obs      =       108
Optimization     : ML                              Residual df     =       106
                                                   Scale parameter =         1
Deviance         =  279.7405364                    (1/df) Deviance =  2.639062
Pearson          =  262.5029208                    (1/df) Pearson  =  2.476443

Variance function: V(u) = u                        [Poisson]
Link function    : g(u) = ln(u)                    [Log]

HAC kernel (lags): Newey-West (4)
                                                   AIC             =  5.814527
Log likelihood   = -311.9844508                    BIC             = -216.5654

------------------------------------------------------------------------------
             |                 HAC
     STRIKES |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      OUTPUT |   3.134217   1.920548     1.63   0.103    -.6299873    6.898421
       _cons |   1.653893   .1033618    16.00   0.000     1.451308    1.856478
------------------------------------------------------------------------------

. estimates store HAC4

. glm STRIKES OUTPUT, family(poisson) vce(hac nwest 8)

Iteration 0:   log likelihood = -313.12939  
Iteration 1:   log likelihood = -311.98566  
Iteration 2:   log likelihood = -311.98445  
Iteration 3:   log likelihood = -311.98445  

Generalized linear models                          No. of obs      =       108
Optimization     : ML                              Residual df     =       106
                                                   Scale parameter =         1
Deviance         =  279.7405364                    (1/df) Deviance =  2.639062
Pearson          =  262.5029208                    (1/df) Pearson  =  2.476443

Variance function: V(u) = u                        [Poisson]
Link function    : g(u) = ln(u)                    [Log]

HAC kernel (lags): Newey-West (8)
                                                   AIC             =  5.814527
Log likelihood   = -311.9844508                    BIC             = -216.5654

------------------------------------------------------------------------------
             |                 HAC
     STRIKES |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      OUTPUT |   3.134217   2.222264     1.41   0.158    -1.221341    7.489774
       _cons |   1.653893   .1162186    14.23   0.000     1.426109    1.881677
------------------------------------------------------------------------------

. estimates store HAC8

. glm STRIKES OUTPUT, family(poisson) vce(hac nwest 12)

Iteration 0:   log likelihood = -313.12939  
Iteration 1:   log likelihood = -311.98566  
Iteration 2:   log likelihood = -311.98445  
Iteration 3:   log likelihood = -311.98445  

Generalized linear models                          No. of obs      =       108
Optimization     : ML                              Residual df     =       106
                                                   Scale parameter =         1
Deviance         =  279.7405364                    (1/df) Deviance =  2.639062
Pearson          =  262.5029208                    (1/df) Pearson  =  2.476443

Variance function: V(u) = u                        [Poisson]
Link function    : g(u) = ln(u)                    [Log]

HAC kernel (lags): Newey-West (12)
                                                   AIC             =  5.814527
Log likelihood   = -311.9844508                    BIC             = -216.5654

------------------------------------------------------------------------------
             |                 HAC
     STRIKES |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      OUTPUT |   3.134217   2.401691     1.31   0.192    -1.573012    7.841445
       _cons |   1.653893   .1231458    13.43   0.000     1.412532    1.895254
------------------------------------------------------------------------------

. estimates store HAC12

. glm STRIKES OUTPUT, family(poisson) vce(hac nwest 16)

Iteration 0:   log likelihood = -313.12939  
Iteration 1:   log likelihood = -311.98566  
Iteration 2:   log likelihood = -311.98445  
Iteration 3:   log likelihood = -311.98445  

Generalized linear models                          No. of obs      =       108
Optimization     : ML                              Residual df     =       106
                                                   Scale parameter =         1
Deviance         =  279.7405364                    (1/df) Deviance =  2.639062
Pearson          =  262.5029208                    (1/df) Pearson  =  2.476443

Variance function: V(u) = u                        [Poisson]
Link function    : g(u) = ln(u)                    [Log]

HAC kernel (lags): Newey-West (16)
                                                   AIC             =  5.814527
Log likelihood   = -311.9844508                    BIC             = -216.5654

------------------------------------------------------------------------------
             |                 HAC
     STRIKES |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      OUTPUT |   3.134217   2.484867     1.26   0.207    -1.736032    8.004466
       _cons |   1.653893   .1267064    13.05   0.000     1.405553    1.902233
------------------------------------------------------------------------------

. estimates store HAC16

. 
. *** TABLE 7.2: POISSON ESTIMATES AND VARIOUS HAC STANDARD ERRORS
. 
. estimates table HAC0 HAC4 HAC8 HAC12 HAC16, b(%9.3f) se

--------------------------------------------------------------------------
    Variable |   HAC0        HAC4        HAC8        HAC12       HAC16    
-------------+------------------------------------------------------------
      OUTPUT |     3.134       3.134       3.134       3.134       3.134  
             |     1.184       1.921       2.222       2.402       2.485  
       _cons |     1.654       1.654       1.654       1.654       1.654  
             |     0.066       0.103       0.116       0.123       0.127  
--------------------------------------------------------------------------
                                                              legend: b/se

. 
. *** FIGURE 7.2: ACTUAL AND PREDICTED STRIKES OVER TIME
. 
. quietly poisson STRIKES OUTPUT, vce(robust)

. predict PREDICTED, n

. correlate STRIKES PREDICTED
(obs=108)

             |  STRIKES PREDIC~D
-------------+------------------
     STRIKES |   1.0000
   PREDICTED |   0.2265   1.0000


. graph twoway (line STRIKES MONTH, lwidth(medthick))                   ///
>   (line PREDICTED MONTH, lpattern(dash) lwidth(medthick)),            ///
>   scale(1.2) legend(ring(0) rows(2) pos(12) label(1 "Actual strikes") ///
>   label(2 "Predicted strikes")) ytitle("Strikes: actual and predicted") 

. graph export racd07fig2.eps, replace
(file racd07fig2.eps written in EPS format)

. graph export racd07fig2.wmf, replace
(file c:\acdbookrevision\stata_final_programs_2013\racd07fig2.wmf written in Windo
> ws Metafile format)

. 
. *** R-SQUAREDS MENTIONED IN TEXT 
. 
. *** Deviance, Pearson and R-squared measures presented in text
. * Fitted model
. quietly glm STRIKES MONTH, family(poisson) vce(robust)

. scalar Devfitted = e(deviance)

. scalar Pearsfitted = e(deviance_p)

. * Intercept-only model
. quietly glm STRIKES, family(poisson) vce(robust)

. scalar Devintercept = e(deviance)

. scalar Pearsintercept = e(deviance_p)

. * Calculate R-squared Deviance and Pearson
. scalar R2_Dev = 1 - Devfitted/Devintercept

. scalar R2_Pears = 1 - Pearsfitted/Pearsintercept

. display "Deviance R-squared = " R2_Dev "   Fitted = " Devfitted "   Intercept = 
> " Devintercept 
Deviance R-squared = .04906826   Fitted = 280.87648   Intercept = 295.36976

. display "Pearson R-squared  = " R2_Pears "   Fitted = " Pearsfitted "   Intercep
> t = " Pearsintercept
Pearson R-squared  = .0241994   Fitted = 280.36165   Intercept = 287.31449

. * Squared correlation coefficient
. quietly correlate STRIKES PREDICTED

. display "Squared correlation coefficient = " r(rho)^2
Squared correlation coefficient = .05128203

. 
. *** TABLE 7.3: RESIDUAL AUTOCORRELATIONS
. 
. * Residuals
. quietly poisson STRIKES OUTPUT, vce(robust)

. predict RESIDUAL, score

. generate PEARSON = RESIDUAL/sqrt(PREDICTED)

. 
. * Autocorrelation functions and Ljung-Box statistics
. * Only use Ljung-Box or Box-Pierce for PEARSON as this is standarndized
. corrgram STRIKES, lags(12)     // Table 7.3 Column 1

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1        0.4936   0.4952   27.049  0.0000          |---               |---     
2        0.4305   0.2514   47.817  0.0000          |---               |--      
3        0.3683   0.1206   63.166  0.0000          |--                |        
4        0.2264  -0.0703   69.023  0.0000          |-                 |        
5        0.1258  -0.0873   70.849  0.0000          |-                 |        
6        0.0387  -0.0798   71.023  0.0000          |                  |        
7        0.0073  -0.0037   71.029  0.0000          |                  |        
8        0.0192   0.0700   71.073  0.0000          |                  |        
9        0.0516   0.0937   71.393  0.0000          |                  |        
10       0.0112  -0.0399   71.408  0.0000          |                  |        
11       0.0560   0.0296   71.793  0.0000          |                  |        
12      -0.0051  -0.1044   71.796  0.0000          |                  |        

. corrgram RESIDUAL, lags(12)    // Table 7.3 Column 2

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1        0.4656   0.4672   24.068  0.0000          |---               |---     
2        0.3983   0.2359   41.846  0.0000          |---               |-       
3        0.3411   0.1214   55.012  0.0000          |--                |        
4        0.1984  -0.0704   59.508  0.0000          |-                 |        
5        0.1106  -0.0709   60.918  0.0000          |                  |        
6        0.0292  -0.0715   61.018  0.0000          |                  |        
7        0.0094   0.0059   61.028  0.0000          |                  |        
8        0.0359   0.0787   61.181  0.0000          |                  |        
9        0.0859   0.1128   62.067  0.0000          |                  |        
10       0.0575  -0.0156   62.468  0.0000          |                  |        
11       0.1038   0.0396   63.786  0.0000          |                  |        
12       0.0302  -0.1121   63.899  0.0000          |                  |        

. corrgram PEARSON, lags(12)     // Table 7.3 Column 3

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1        0.4424   0.4440   21.731  0.0000          |---               |---     
2        0.3760   0.2283   37.574  0.0000          |---               |-       
3        0.3231   0.1234   49.387  0.0000          |--                |        
4        0.2025  -0.0369    54.07  0.0000          |-                 |        
5        0.1084  -0.0719   55.426  0.0000          |                  |        
6        0.0298  -0.0750    55.53  0.0000          |                  |        
7        0.0148   0.0012   55.556  0.0000          |                  |        
8        0.0382   0.0718   55.729  0.0000          |                  |        
9        0.0814   0.1015   56.524  0.0000          |                  |        
10       0.0452  -0.0193   56.772  0.0000          |                  |        
11       0.0996   0.0541   57.987  0.0000          |                  |        
12       0.0297  -0.0941   58.096  0.0000          |                  |        

. 
. * Get the z statistics by multiply autocorrelations by sqrt(T)
. scalar sqrtT = sqrt(_N)     

. quietly corrgram PEARSON, lags(12)

. matrix Zstatistics = r(AC)*I(12)*sqrtT

. matrix list Zstatistics       // Table 7.3 Column 4

Zstatistics[1,12]
           c1         c2         c3         c4         c5         c6         c7
r1  4.5976771  3.9072342   3.358009  2.1042274  1.1268802  .30993607  .15427008

           c8         c9        c10        c11        c12
r1  .39707453  .84583092  .46950439  1.0352169  .30876908

. 
. * Compute the BP statistic (corrgram gives the LB statistics)
. matrix ZstatisticsSQ = hadamard(Zstatistics,Zstatistics)

. matrix BP = trace(diag(ZstatisticsSQ))

. matrix list BP

symmetric BP[1,1]
           c1
r1  55.759374

. 
. * Nonstandardized case
. * Applied just for PEARSON where not necessary as standardized
. * But can also apply to nonstandardized such as RESIDUAL
. scalar TBPstar = 0

. forvalues i = 1/12 {
  2.   quietly generate PL`i' = L`i'.PEARSON
  3.   quietly generate PL0PL`i' = PEARSON*PL`i'
  4.   quietly generate PL0SQPL`i'SQ = PEARSON*PEARSON*PL`i'*PL`i'
  5.   quietly sum PL0PL`i'
  6.   scalar NUMERATOR = r(sum)
  7.   quietly sum PL0SQPL`i'SQ
  8.   scalar DENOMINATOR = sqrt(r(sum))
  9.   scalar T`i'star = NUMERATOR / DENOMINATOR
 10.   scalar T`i'starSQ = T`i'star^2
 11.   scalar TBPstar = TBPstar + T`i'starSQ
 12.   }

. * List the individual statistics T* at lags 1 to 12
. scalar list T1star T2star T3star T4star T5star T6star T7star T8star ///
>    T9star T10star T11star T12star               // Table 7.3 Column 5
    T1star =   4.070692
    T2star =   3.960054
    T3star =  3.3988374
    T4star =  2.2138469
    T5star =  1.2238748
    T6star =  .32778475
    T7star =  .16866481
    T8star =  .43577439
    T9star =  1.0631306
   T10star =  .54491829
   T11star =   1.170747
   T12star =  .37589509

. * List the overall test
. scalar list TBPstar
   TBPstar =  53.468562

. 
. * Yet another test
. regress PEARSON L.PEARSON L2.PEARSON  L3.PEARSON L4.PEARSON L5.PEARSON  ///
>   L6.PEARSON L7.PEARSON  L8.PEARSON L9.PEARSON  L10.PEARSON L11.PEARSON ///
>   L12.PEARSON , vce(robust)

Linear regression                                      Number of obs =      96
                                                       F( 12,    83) =    3.90
                                                       Prob > F      =  0.0001
                                                       R-squared     =  0.3309
                                                       Root MSE      =  1.3351

------------------------------------------------------------------------------
             |               Robust
     PEARSON |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
     PEARSON |
         L1. |   .3136083   .1091597     2.87   0.005     .0964939    .5307226
         L2. |   .2319255   .1131578     2.05   0.044     .0068591    .4569918
         L3. |   .2054849   .1152998     1.78   0.078    -.0238418    .4348116
         L4. |  -.0007533   .1117113    -0.01   0.995    -.2229426    .2214361
         L5. |   -.094714   .1234872    -0.77   0.445    -.3403251     .150897
         L6. |  -.1578701   .1325787    -1.19   0.237    -.4215638    .1058235
         L7. |   -.044766   .1265306    -0.35   0.724    -.2964302    .2068983
         L8. |   .1505729   .1213462     1.24   0.218    -.0907798    .3919255
         L9. |   .1078921    .092864     1.16   0.249    -.0768106    .2925948
        L10. |  -.0416191   .0937056    -0.44   0.658    -.2279958    .1447577
        L11. |   .0639839   .1059063     0.60   0.547    -.1466596    .2746273
        L12. |  -.0941421   .1030877    -0.91   0.364    -.2991795    .1108953
             |
       _cons |  -.0326778   .1432344    -0.23   0.820    -.3175652    .2522096
------------------------------------------------------------------------------

. display "chisquare(12) test = " 12*e(F)
chisquare(12) test = 46.753833

. 
. * Yet another test number two
. regress PEARSON OUTPUT L.PEARSON L2.PEARSON  L3.PEARSON L4.PEARSON L5.PEARSON  /
> //
>   L6.PEARSON L7.PEARSON  L8.PEARSON L9.PEARSON  L10.PEARSON L11.PEARSON ///
>   L12.PEARSON , vce(robust)

Linear regression                                      Number of obs =      96
                                                       F( 13,    82) =    3.96
                                                       Prob > F      =  0.0001
                                                       R-squared     =  0.3365
                                                       Root MSE      =  1.3375

------------------------------------------------------------------------------
             |               Robust
     PEARSON |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      OUTPUT |   2.511773   3.019764     0.83   0.408      -3.4955    8.519046
             |
     PEARSON |
         L1. |    .307679   .1098356     2.80   0.006      .089181    .5261769
         L2. |   .2341558    .113006     2.07   0.041     .0093508    .4589608
         L3. |   .2091645    .117633     1.78   0.079    -.0248449     .443174
         L4. |   .0017562   .1134431     0.02   0.988    -.2239183    .2274307
         L5. |  -.0861634   .1217861    -0.71   0.481    -.3284348    .1561079
         L6. |  -.1531775   .1320841    -1.16   0.250    -.4159347    .1095798
         L7. |  -.0401237   .1279615    -0.31   0.755    -.2946798    .2144324
         L8. |    .158914   .1205803     1.32   0.191    -.0809588    .3987867
         L9. |    .113676   .0951239     1.20   0.236    -.0755557    .3029077
        L10. |  -.0251899   .0993199    -0.25   0.800    -.2227688     .172389
        L11. |   .0813878   .1074369     0.76   0.451    -.1323385    .2951141
        L12. |  -.0778885   .1039529    -0.75   0.456     -.284684    .1289069
             |
       _cons |   -.019741   .1417809    -0.14   0.890    -.3017883    .2623064
------------------------------------------------------------------------------

. display "chisquare(12) test = " 12*e(F)
chisquare(12) test = 47.464111

. 
. *** TABLE 7.4: PREDICTED PROBABILITIES
. 
. quietly poisson STRIKES OUTPUT

. forvalues i = 0/10 {
  2.    predict poissfit`i', pr(`i')
  3.    }

. quietly nbreg STRIKES OUTPUT

. forvalues i = 0/10 {
  2.    predict nb2fit`i', pr(`i')
  3.    }

. * Table 7.4
. sum poissfit*

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
   poissfit0 |       108    .0076184    .0069674   .0010759   .0343531
   poissfit1 |       108    .0345675     .024319   .0073535   .1158065
   poissfit2 |       108    .0807541    .0412888    .025129   .1951955
   poissfit3 |       108    .1294987    .0437067   .0572487   .2193387
   poissfit4 |       108    .1602776     .029413   .0978176   .1953638
-------------+--------------------------------------------------------
   poissfit5 |       108    .1631451    .0133924    .124629   .1754655
   poissfit6 |       108    .1420717    .0219649    .070022   .1606056
   poissfit7 |       108    .1086961    .0306992   .0337212   .1487071
   poissfit8 |       108    .0744539     .030817   .0142095   .1270437
   poissfit9 |       108    .0462992     .025213   .0053224   .0964766
-------------+--------------------------------------------------------
  poissfit10 |       108    .0264159    .0177871   .0017942   .0659377

. sum nb2fit*

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     nb2fit0 |       108    .0487021    .0174928   .0255538   .1024384
     nb2fit1 |       108    .0935452    .0262514   .0556516    .166719
     nb2fit2 |       108    .1186588    .0244708   .0796266   .1782651
     nb2fit3 |       108    .1249444     .017006   .0941028   .1574386
     nb2fit4 |       108    .1182736    .0085172   .0994948   .1281893
-------------+--------------------------------------------------------
     nb2fit5 |       108    .1045348    .0036342   .0913453   .1077284
     nb2fit6 |       108     .088103    .0065444   .0636757    .092988
     nb2fit7 |       108    .0717301    .0094165   .0426949   .0818209
     nb2fit8 |       108    .0568971    .0107421   .0277759   .0712288
     nb2fit9 |       108    .0442295    .0108498   .0176394   .0605299
-------------+--------------------------------------------------------
    nb2fit10 |       108    .0338376    .0101716   .0109832   .0504332

. 
. * Aside: If instead use user-written addon countfit
. countfit STRIKES OUTPUT, maxcount(10) prm nograph

--------------------------------------------
                      Variable |    PRM     
-------------------------------+------------
Deviation of monthly industr~  |    22.971  
                               |      3.90  
                      Constant |     5.227  
                               |     39.15  
-------------------------------+------------
                         alpha |            
                             N |       108  
                            ll |  -311.984  
                           bic |   633.333  
                           aic |   627.969  
--------------------------------------------
                                 legend: b/t
Comparison of Mean Observed and Predicted Count

            Maximum       At      Mean
Model     Difference    Value    |Diff|
---------------------------------------------
PRM        -0.077         4      0.047

PRM: Predicted and actual probabilities

Count   Actual    Predicted    |Diff|   Pearson
------------------------------------------------
0        0.046       0.008      0.039    21.207
1        0.111       0.035      0.077    18.305
2        0.130       0.081      0.049     3.195
3        0.102       0.129      0.028     0.637
4        0.083       0.160      0.077     3.989
5        0.130       0.163      0.034     0.744
6        0.083       0.142      0.059     2.623
7        0.037       0.109      0.072     5.102
8        0.065       0.074      0.010     0.135
9        0.093       0.046      0.046     4.999
10       0.056       0.026      0.029     3.472
------------------------------------------------
Sum      0.935       0.974      0.518    64.408

Tests and Fit Statistics

PRM            BIC=   127.663  AIC=     5.815  Prefer  Over  Evidence

. drop PRM*

. countfit STRIKES OUTPUT, maxcount(10) nbreg nograph

--------------------------------------------
                      Variable |   NBRM     
-------------------------------+------------
STRIKES                        |
Deviation of monthly industr~  |    25.153  
                               |      2.48  
                      Constant |     5.227  
                               |     24.11  
-------------------------------+------------
lnalpha                        |
                      Constant |     0.314  
                               |     -4.99  
-------------------------------+------------
Statistics                     |            
                         alpha |     0.314  
                             N |       108  
                            ll |  -280.298  
                           bic |   574.643  
                           aic |   566.597  
--------------------------------------------
                                 legend: b/t
Comparison of Mean Observed and Predicted Count

            Maximum       At      Mean
Model     Difference    Value    |Diff|
---------------------------------------------
NBRM        0.048         9      0.021

NBRM: Predicted and actual probabilities

Count   Actual    Predicted    |Diff|   Pearson
------------------------------------------------
0        0.046       0.049      0.002     0.013
1        0.111       0.094      0.018     0.356
2        0.130       0.119      0.011     0.110
3        0.102       0.125      0.023     0.461
4        0.083       0.118      0.035     1.115
5        0.130       0.105      0.025     0.651
6        0.083       0.088      0.005     0.028
7        0.037       0.072      0.035     1.812
8        0.065       0.057      0.008     0.119
9        0.093       0.044      0.048     5.711
10       0.056       0.034      0.022     1.505
------------------------------------------------
Sum      0.935       0.903      0.232    11.881

Tests and Fit Statistics

-------------------------------------------------------------------------
NBRM           BIC=    68.973  AIC=     5.246  Prefer  Over  Evidence

. drop NBRM*

. 
. **********  7.11.1 DYNAMIC REGRESSION FOR STRIKES DATA
. 
. use racd07data1strikes.dta, clear

. 
. generate ystar = STRIKES

. replace ystar = 0.5 if ystar == 0
(5 real changes made)

. generate lnystar = ln(ystar)

. generate ytwostar = STRIKES

. replace ytwostar = 1 if STRIKES == 0
(5 real changes made)

. generate dy0 = STRIKES == 0

. generate lnytwostar = ln(ytwostar)

. summarize

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     STRIKES |       108    5.240741    3.751312          0         18
      OUTPUT |       108   -.0036954    .0545578    -.13996     .08554
       MONTH |       108        54.5    31.32092          1        108
       ystar |       108    5.263889    3.720026         .5         18
     lnystar |       108    1.352305    .8739339  -.6931472   2.890372
-------------+--------------------------------------------------------
    ytwostar |       108    5.287037    3.691493          1         18
         dy0 |       108    .0462963    .2111056          0          1
  lnytwostar |       108    1.384395    .8078784          0   2.890372

. 
. * Zeger-Qaqish model with y* = max(y,0.5) and up to three lags
. poisson STRIKES OUTPUT, vce(robust)

Iteration 0:   log pseudolikelihood = -311.98445  
Iteration 1:   log pseudolikelihood = -311.98445  

Poisson regression                                Number of obs   =        108
                                                  Wald chi2(1)    =       7.01
                                                  Prob > chi2     =     0.0081
Log pseudolikelihood = -311.98445                 Pseudo R2       =     0.0244

------------------------------------------------------------------------------
             |               Robust
     STRIKES |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      OUTPUT |   3.134217    1.18364     2.65   0.008     .8143251    5.454109
       _cons |   1.653893   .0659347    25.08   0.000     1.524663    1.783123
------------------------------------------------------------------------------

. estimates store ZQ0

. predict yhatZQ0, n

. predict resZQ0, score

. generate pearsZQ0 = resZQ0 / sqrt(yhatZQ0) 

. 
. poisson STRIKES OUTPUT L.lnystar, vce(robust)

Iteration 0:   log pseudolikelihood =  -281.8789  
Iteration 1:   log pseudolikelihood = -281.87875  
Iteration 2:   log pseudolikelihood = -281.87875  

Poisson regression                                Number of obs   =        107
                                                  Wald chi2(2)    =      26.73
                                                  Prob > chi2     =     0.0000
Log pseudolikelihood = -281.87875                 Pseudo R2       =     0.1137

------------------------------------------------------------------------------
             |               Robust
     STRIKES |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      OUTPUT |   2.330121   1.025622     2.27   0.023     .3199396    4.340302
             |
     lnystar |
         L1. |   .3960842   .0854108     4.64   0.000      .228682    .5634863
             |
       _cons |   1.060482   .1569562     6.76   0.000     .7528531     1.36811
------------------------------------------------------------------------------

. estimates store ZQ1

. predict yhatZQ1, n
(1 missing value generated)

. predict resZQ1, score
(1 missing values generated)

. predict STRIKESZQ1, xb
(1 missing value generated)

. generate pearsZQ1 = resZQ1 / sqrt(yhatZQ1) 
(1 missing value generated)

. 
. poisson STRIKES OUTPUT L.lnystar L2.lnystar, vce(robust)

Iteration 0:   log pseudolikelihood = -273.95126  
Iteration 1:   log pseudolikelihood = -273.95121  
Iteration 2:   log pseudolikelihood = -273.95121  

Poisson regression                                Number of obs   =        106
                                                  Wald chi2(3)    =      44.21
                                                  Prob > chi2     =     0.0000
Log pseudolikelihood = -273.95121                 Pseudo R2       =     0.1338

------------------------------------------------------------------------------
             |               Robust
     STRIKES |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      OUTPUT |   2.192131   1.019296     2.15   0.032     .1943484    4.189914
             |
     lnystar |
         L1. |   .2952177   .0903188     3.27   0.001     .1181961    .4722393
         L2. |   .2045283   .0746091     2.74   0.006     .0582972    .3507593
             |
       _cons |   .9108763   .1511642     6.03   0.000     .6145999    1.207153
------------------------------------------------------------------------------

. predict yhatZQ2, n
(2 missing values generated)

. estimates store ZQ2

. predict resZQ2, score
(2 missing values generated)

. generate pearsZQ2 = resZQ2 / sqrt(yhatZQ2) 
(2 missing values generated)

. 
. poisson STRIKES OUTPUT L.lnystar L2.lnystar L3.lnystar, vce(robust)

Iteration 0:   log pseudolikelihood = -270.21687  
Iteration 1:   log pseudolikelihood = -270.21684  
Iteration 2:   log pseudolikelihood = -270.21684  

Poisson regression                                Number of obs   =        105
                                                  Wald chi2(4)    =      49.59
                                                  Prob > chi2     =     0.0000
Log pseudolikelihood = -270.21684                 Pseudo R2       =     0.1405

------------------------------------------------------------------------------
             |               Robust
     STRIKES |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      OUTPUT |   2.186976   1.018009     2.15   0.032     .1917146    4.182237
             |
     lnystar |
         L1. |   .2673958   .0886387     3.02   0.003     .0936672    .4411244
         L2. |   .1629449   .0759702     2.14   0.032     .0140461    .3118438
         L3. |   .1141639   .0726625     1.57   0.116     -.028252    .2565798
             |
       _cons |   .8461776   .1560318     5.42   0.000     .5403609    1.151994
------------------------------------------------------------------------------

. predict yhatZQ3, n
(3 missing values generated)

. estimates store ZQ3

. predict resZQ3, score
(3 missing values generated)

. generate pearsZQ3 = resZQ3 / sqrt(yhatZQ3) 
(3 missing values generated)

. 
. * Use following to get the Pearson statistic for NB1 overdispersion
. glm STRIKES OUTPUT L.lnystar L2.lnystar L3.lnystar, family(poisson) vce(robust)

Iteration 0:   log pseudolikelihood =  -271.3121  
Iteration 1:   log pseudolikelihood = -270.21813  
Iteration 2:   log pseudolikelihood = -270.21684  
Iteration 3:   log pseudolikelihood = -270.21684  

Generalized linear models                          No. of obs      =       105
Optimization     : ML                              Residual df     =       100
                                                   Scale parameter =         1
Deviance         =  206.6090612                    (1/df) Deviance =  2.066091
Pearson          =  196.9740327                    (1/df) Pearson  =   1.96974

Variance function: V(u) = u                        [Poisson]
Link function    : g(u) = ln(u)                    [Log]

                                                   AIC             =  5.242226
Log pseudolikelihood = -270.2168402                BIC             =  -258.787

------------------------------------------------------------------------------
             |               Robust
     STRIKES |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      OUTPUT |   2.186976   1.018009     2.15   0.032     .1917146    4.182237
             |
     lnystar |
         L1. |   .2673958   .0886387     3.02   0.003     .0936672    .4411244
         L2. |   .1629449   .0759702     2.14   0.032     .0140461    .3118438
         L3. |   .1141639   .0726625     1.57   0.116     -.028252    .2565798
             |
       _cons |   .8461776   .1560318     5.42   0.000     .5403609    1.151994
------------------------------------------------------------------------------

. 
. poisson STRIKES OUTPUT L.lnytwostar L.dy0, vce(robust)

Iteration 0:   log pseudolikelihood = -277.24805  
Iteration 1:   log pseudolikelihood = -277.24802  
Iteration 2:   log pseudolikelihood = -277.24802  

Poisson regression                                Number of obs   =        107
                                                  Wald chi2(3)    =      44.42
                                                  Prob > chi2     =     0.0000
Log pseudolikelihood = -277.24802                 Pseudo R2       =     0.1283

------------------------------------------------------------------------------
             |               Robust
     STRIKES |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      OUTPUT |   2.344704   1.038471     2.26   0.024     .3093384    4.380069
             |
  lnytwostar |
         L1. |   .4821869   .0835737     5.77   0.000     .3183854    .6459883
             |
         dy0 |
         L1. |   .5526772    .383839     1.44   0.150    -.1996334    1.304988
             |
       _cons |   .8959762   .1569278     5.71   0.000     .5884033    1.203549
------------------------------------------------------------------------------

. estimates store ZQ1c

. predict yhatZQ1c, n
(1 missing value generated)

. predict resZQ1c, score
(1 missing values generated)

. generate pearsZQ1c = resZQ1c / sqrt(yhatZQ1c) 
(1 missing value generated)

. 
. estimates table ZQ0 ZQ1 ZQ2 ZQ3 ZQ1c, b(%9.3f) se

--------------------------------------------------------------------------
    Variable |    ZQ0         ZQ1         ZQ2         ZQ3        ZQ1c     
-------------+------------------------------------------------------------
      OUTPUT |     3.134       2.330       2.192       2.187       2.345  
             |     1.184       1.026       1.019       1.018       1.038  
             |
     lnystar |
         L1. |                 0.396       0.295       0.267              
             |                 0.085       0.090       0.089              
         L2. |                             0.205       0.163              
             |                             0.075       0.076              
         L3. |                                         0.114              
             |                                         0.073              
             |
  lnytwostar |
         L1. |                                                     0.482  
             |                                                     0.084  
             |
         dy0 |
         L1. |                                                     0.553  
             |                                                     0.384  
             |
       _cons |     1.654       1.060       0.911       0.846       0.896  
             |     0.066       0.157       0.151       0.156       0.157  
--------------------------------------------------------------------------
                                                              legend: b/se

. 
. * Brannas Conditional NL of INAR(1) model
. generate yL1 = L.STRIKES
(1 missing value generated)

. generate yL2 = L2.STRIKES
(2 missing values generated)

. generate yL3 = L3.STRIKES
(3 missing values generated)

. 
. * Compare NLS of static model with Poisson of static model earlier
. nl (STRIKES = exp({beta1}+{beta2}*OUTPUT) ), vce(robust)
(obs = 108)

Iteration 0:  residual SS =   2001.92
Iteration 1:  residual SS =  1587.385
Iteration 2:  residual SS =   1429.73
Iteration 3:  residual SS =  1428.403
Iteration 4:  residual SS =  1428.403
Iteration 5:  residual SS =  1428.403
Iteration 6:  residual SS =  1428.403

Nonlinear regression                                 Number of obs =       108
                                                     R-squared     =    0.6806
                                                     Adj R-squared =    0.6746
                                                     Root MSE      =  3.670899
                                                     Res. dev.     =  585.3662

------------------------------------------------------------------------------
             |               Robust
     STRIKES |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      /beta1 |   1.655173   .0663836    24.93   0.000     1.523561    1.786785
      /beta2 |   2.992699   1.274886     2.35   0.021     .4651126    5.520286
------------------------------------------------------------------------------

. estimates store B0

. predict yhatB0, yhat

. predict resB0, residual

. generate pearsB0 = resB0 / sqrt(yhatB0) 

. 
. nl (STRIKES = {rho1}*yL1 + exp({beta1}+{beta2}*OUTPUT) ) if yL1 != ., initial(rh
> o1 0.5) vce(robust)
(obs = 107)

Iteration 0:  residual SS =  1115.913
Iteration 1:  residual SS =  1110.086
Iteration 2:  residual SS =  1109.951
Iteration 3:  residual SS =  1109.951
Iteration 4:  residual SS =  1109.951
Iteration 5:  residual SS =  1109.951

Nonlinear regression                                 Number of obs =       107
                                                     R-squared     =    0.7504
                                                     Adj R-squared =    0.7432
                                                     Root MSE      =  3.266895
                                                     Res. dev.     =  553.9518

------------------------------------------------------------------------------
             |               Robust
     STRIKES |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       /rho1 |    .469088   .0931431     5.04   0.000     .2843817    .6537942
      /beta1 |    1.01705     .19053     5.34   0.000     .6392217    1.394878
      /beta2 |   3.479712   2.129436     1.63   0.105    -.7430399    7.702464
------------------------------------------------------------------------------

. estimates store B1

. predict yhatB1, yhat

. predict resB1, residual

. generate pearsB1 = resB1 / sqrt(yhatB1) 
(1 missing value generated)

. 
. nl (STRIKES = {rho1}*yL1 + {rho2}*yL2 + exp({beta1}+{beta2}*OUTPUT) ) if (yL1 !=
>  . & yL2 != .), initial(rho1 0.4 rho2 0.1) vce(robust)
(obs = 106)

Iteration 0:  residual SS =  1368.979
Iteration 1:  residual SS =  1055.534
Iteration 2:  residual SS =  1040.838
Iteration 3:  residual SS =  1040.745
Iteration 4:  residual SS =  1040.745
Iteration 5:  residual SS =  1040.745
Iteration 6:  residual SS =  1040.745

Nonlinear regression                                 Number of obs =       106
                                                     R-squared     =    0.7651
                                                     Adj R-squared =    0.7559
                                                     Root MSE      =  3.194273
                                                     Res. dev.     =  542.9457

------------------------------------------------------------------------------
             |               Robust
     STRIKES |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       /rho1 |   .3504213   .1008956     3.47   0.001     .1502953    .5505472
       /rho2 |   .2452067   .0754637     3.25   0.002     .0955249    .3948886
      /beta1 |   .7388908   .2462053     3.00   0.003     .2505437    1.227238
      /beta2 |   4.310547   2.851579     1.51   0.134    -1.345547    9.966641
------------------------------------------------------------------------------

. estimates store B2

. predict yhatB2, yhat

. predict resB2, residual

. generate pearsB2 = resB2 / sqrt(yhatB2) 
(2 missing values generated)

. 
. nl (STRIKES = {rho1}*yL1 + {rho2}*yL2 + {rho3}*yL3 + exp({beta1}+{beta2}*OUTPUT)
>  ) if (yL1 != . & yL2 != . & yL3 != .), initial(rho1 0.3 rho2 0.1 rho1 0.1) vce(
> robust)
(obs = 105)

Iteration 0:  residual SS =  1152.956
Iteration 1:  residual SS =  1026.946
Iteration 2:  residual SS =  1022.548
Iteration 3:  residual SS =  1022.535
Iteration 4:  residual SS =  1022.535
Iteration 5:  residual SS =  1022.535

Nonlinear regression                                 Number of obs =       105
                                                     R-squared     =    0.7673
                                                     Adj R-squared =    0.7557
                                                     Root MSE      =  3.197711
                                                     Res. dev.     =  536.9655

------------------------------------------------------------------------------
             |               Robust
     STRIKES |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       /rho1 |   .3193948    .099663     3.20   0.002     .1216662    .5171233
       /rho2 |   .1978621    .083844     2.36   0.020     .0315179    .3642062
       /rho3 |   .1266174   .0846741     1.50   0.138    -.0413736    .2946085
      /beta1 |   .5968779   .3088189     1.93   0.056      -.01581    1.209566
      /beta2 |   5.106664   3.437279     1.49   0.141    -1.712801    11.92613
------------------------------------------------------------------------------

. estimates store B3

. predict yhatB3, yhat

. predict resB3, residual

. generate pearsB3 = resB3 / sqrt(yhatB3) 
(3 missing values generated)

. 
. *** TABLE 7.5: STRIKES ZEGER-QAQISH AUTORGEGRESSIVE MODEL ESTIMATES
. 
. * First four columns of Table 7.5
. estimates table ZQ0 ZQ1 ZQ2 ZQ3 ZQ1c, b(%9.3f) se

--------------------------------------------------------------------------
    Variable |    ZQ0         ZQ1         ZQ2         ZQ3        ZQ1c     
-------------+------------------------------------------------------------
      OUTPUT |     3.134       2.330       2.192       2.187       2.345  
             |     1.184       1.026       1.019       1.018       1.038  
             |
     lnystar |
         L1. |                 0.396       0.295       0.267              
             |                 0.085       0.090       0.089              
         L2. |                             0.205       0.163              
             |                             0.075       0.076              
         L3. |                                         0.114              
             |                                         0.073              
             |
  lnytwostar |
         L1. |                                                     0.482  
             |                                                     0.084  
             |
         dy0 |
         L1. |                                                     0.553  
             |                                                     0.384  
             |
       _cons |     1.654       1.060       0.911       0.846       0.896  
             |     0.066       0.157       0.151       0.156       0.157  
--------------------------------------------------------------------------
                                                              legend: b/se

. 
. * Last three columns of Table 7.5
. estimates table B0 B1 B2 B3, b(%9.3f) se

--------------------------------------------------------------
    Variable |    B0          B1          B2          B3      
-------------+------------------------------------------------
beta1        |
       _cons |     1.655       1.017       0.739       0.597  
             |     0.066       0.191       0.246       0.309  
-------------+------------------------------------------------
beta2        |
       _cons |     2.993       3.480       4.311       5.107  
             |     1.275       2.129       2.852       3.437  
-------------+------------------------------------------------
rho1         |
       _cons |                 0.469       0.350       0.319  
             |                 0.093       0.101       0.100  
-------------+------------------------------------------------
rho2         |
       _cons |                             0.245       0.198  
             |                             0.075       0.084  
-------------+------------------------------------------------
rho3         |
       _cons |                                         0.127  
             |                                         0.085  
--------------------------------------------------------------
                                                  legend: b/se

. 
. * Correlations - The squares of these are given in second last row of Table 7.5
. correlate STRIKES yhatZQ0 yhatZQ1 yhatZQ2 yhatZQ3 yhatZQ1c yhatB0 yhatB1 yhatB2 
> yhatB3
(obs=105)

             |  STRIKES  yhatZQ0  yhatZQ1  yhatZQ2  yhatZQ3 yhatZQ1c   yhatB0
-------------+---------------------------------------------------------------
     STRIKES |   1.0000
     yhatZQ0 |   0.2271   1.0000
     yhatZQ1 |   0.5273   0.4575   1.0000
     yhatZQ2 |   0.5616   0.4179   0.9279   1.0000
     yhatZQ3 |   0.5745   0.4045   0.9093   0.9789   1.0000
    yhatZQ1c |   0.5409   0.4241   0.9676   0.9120   0.8993   1.0000
      yhatB0 |   0.2274   1.0000   0.4578   0.4182   0.4050   0.4244   1.0000
      yhatB1 |   0.5136   0.4393   0.9781   0.9085   0.8933   0.9676   0.4396
      yhatB2 |   0.5556   0.4063   0.9136   0.9831   0.9667   0.9130   0.4067
      yhatB3 |   0.5656   0.3980   0.8986   0.9663   0.9854   0.9040   0.3983

             |   yhatB1   yhatB2   yhatB3
-------------+---------------------------
      yhatB1 |   1.0000
      yhatB2 |   0.9237   1.0000
      yhatB3 |   0.9077   0.9823   1.0000


. summarize STRIKES yhatZQ0 yhatZQ1 yhatZQ2 yhatZQ3 yhatZQ1c yhatB0 yhatB1 yhatB2 
> yhatB3

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     STRIKES |       108    5.240741    3.751312          0         18
     yhatZQ0 |       108    5.240741    .8691222   3.371063   6.834573
     yhatZQ1 |       107    5.242991    1.883666   1.747631   10.51237
     yhatZQ2 |       106    5.254717    2.072169   2.234505    11.6646
     yhatZQ3 |       105    5.247619    2.139702   2.208586   11.58084
-------------+--------------------------------------------------------
    yhatZQ1c |       107    5.242991    2.031151   1.917685   11.44826
      yhatB0 |       108     5.24372    .8314178   3.442904   6.760987
      yhatB1 |       107     5.24451    1.928011   1.968058   11.88861
      yhatB2 |       106    5.256538    2.096139    2.17558   12.73479
      yhatB3 |       105    5.249399     2.14625   2.198303    12.3648

. 
. * Autocorrelations
. corrgram STRIKES, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1        0.4936   0.4952   27.049  0.0000          |---               |---     
2        0.4305   0.2514   47.817  0.0000          |---               |--      
3        0.3683   0.1206   63.166  0.0000          |--                |        
4        0.2264  -0.0703   69.023  0.0000          |-                 |        
5        0.1258  -0.0873   70.849  0.0000          |-                 |        
6        0.0387  -0.0798   71.023  0.0000          |                  |        

. corrgram resZQ0, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1        0.4656   0.4672   24.068  0.0000          |---               |---     
2        0.3983   0.2359   41.846  0.0000          |---               |-       
3        0.3411   0.1214   55.012  0.0000          |--                |        
4        0.1984  -0.0704   59.508  0.0000          |-                 |        
5        0.1106  -0.0709   60.918  0.0000          |                  |        
6        0.0292  -0.0715   61.018  0.0000          |                  |        

. corrgram resZQ1, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.0859  -0.0860   .81222  0.3675          |                  |        
2        0.1400   0.1353   2.9882  0.2245          |-                 |-       
3        0.1834   0.2163   6.7589  0.0800          |-                 |-       
4        0.0328   0.0454   6.8806  0.1423          |                  |        
5        0.0280  -0.0264     6.97  0.2229          |                  |        
6       -0.0406  -0.0986     7.16  0.3063          |                  |        

. corrgram resZQ2, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.0178  -0.0178   .03451  0.8526          |                  |        
2       -0.0218  -0.0222   .08688  0.9575          |                  |        
3        0.1464   0.1490   2.4686  0.4810          |-                 |-       
4        0.0040   0.0042   2.4704  0.6499          |                  |        
5       -0.0100  -0.0038   2.4817  0.7792          |                  |        
6       -0.0753  -0.1014   3.1304  0.7923          |                  |        

. corrgram resZQ3, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1        0.0124   0.0125   .01656  0.8976          |                  |        
2        0.0441   0.0446   .22867  0.8920          |                  |        
3        0.0462   0.0445   .46358  0.9268          |                  |        
4       -0.0041  -0.0082   .46542  0.9768          |                  |        
5       -0.0419  -0.0454   .66247  0.9850          |                  |        
6       -0.1234  -0.1246    2.391  0.8805          |                  |        

. corrgram resZQ1c, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.1299  -0.1300   1.8575  0.1729         -|                 -|        
2        0.1268   0.1133   3.6432  0.1618          |-                 |        
3        0.1577   0.1984   6.4339  0.0923          |-                 |-       
4        0.0056   0.0300   6.4375  0.1688          |                  |        
5        0.0009  -0.0466   6.4376  0.2659          |                  |        
6       -0.0334  -0.0795   6.5665  0.3628          |                  |        

. corrgram resB0, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1        0.4657   0.4673   24.075  0.0000          |---               |---     
2        0.3985   0.2361    41.87  0.0000          |---               |-       
3        0.3411   0.1212   55.037  0.0000          |--                |        
4        0.1983  -0.0705   59.528  0.0000          |-                 |        
5        0.1099  -0.0717   60.922  0.0000          |                  |        
6        0.0283  -0.0721   61.015  0.0000          |                  |        

. corrgram resB1, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.1203  -0.1204   1.5921  0.2070          |                  |        
2        0.1377   0.1265   3.6993  0.1573          |-                 |-       
3        0.1708   0.2123   6.9704  0.0728          |-                 |-       
4        0.0346   0.0573   7.1057  0.1304          |                  |        
5        0.0307  -0.0157   7.2136  0.2052          |                  |        
6       -0.0283  -0.0816   7.3061  0.2935          |                  |        

. corrgram resB2, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.0312  -0.0313    .1064  0.7443          |                  |        
2       -0.0373  -0.0388    .2596  0.8783          |                  |        
3        0.1334   0.1348   2.2382  0.5245          |-                 |-       
4        0.0073   0.0099   2.2441  0.6910          |                  |        
5       -0.0246  -0.0172   2.3125  0.8044          |                  |        
6       -0.0760  -0.0989   2.9731  0.8122          |                  |        

. corrgram resB3, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.0054  -0.0053    .0032  0.9549          |                  |        
2        0.0323   0.0332   .11707  0.9431          |                  |        
3        0.0409   0.0403   .30138  0.9598          |                  |        
4       -0.0104  -0.0128   .31339  0.9889          |                  |        
5       -0.0589  -0.0624   .70293  0.9828          |                  |        
6       -0.1218  -0.1239   2.3871  0.8809          |                  |        

. 
. ** TABLE 7.5: For LB test use the (standardized) Pearson residuals
. corrgram pearsZQ0, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1        0.4424   0.4440   21.731  0.0000          |---               |---     
2        0.3760   0.2283   37.574  0.0000          |---               |-       
3        0.3231   0.1234   49.387  0.0000          |--                |        
4        0.2025  -0.0369    54.07  0.0000          |-                 |        
5        0.1084  -0.0719   55.426  0.0000          |                  |        
6        0.0298  -0.0750    55.53  0.0000          |                  |        

. corrgram pearsZQ1, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.1015  -0.1016   1.1339  0.2870          |                  |        
2        0.1326   0.1249   3.0864  0.2137          |-                 |        
3        0.1570   0.1912   5.8512  0.1191          |-                 |-       
4        0.0777   0.0992   6.5344  0.1626          |                  |        
5        0.0328   0.0050   6.6576  0.2474          |                  |        
6        0.0042  -0.0490   6.6596  0.3535          |                  |        

. corrgram pearsZQ2, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.0068  -0.0068   .00502  0.9435          |                  |        
2       -0.0240  -0.0240   .06818  0.9665          |                  |        
3        0.1215   0.1239   1.7087  0.6350          |                  |        
4        0.0403   0.0399   1.8907  0.7559          |                  |        
5        0.0210   0.0277   1.9406  0.8573          |                  |        
6       -0.0155  -0.0288    1.968  0.9226          |                  |        

. corrgram pearsZQ3, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1        0.0156   0.0158   .02638  0.8710          |                  |        
2        0.0525   0.0531   .32697  0.8492          |                  |        
3        0.0257   0.0234   .39994  0.9403          |                  |        
4        0.0139   0.0104   .42135  0.9807          |                  |        
5       -0.0097  -0.0116   .43183  0.9944          |                  |        
6       -0.0599  -0.0604   .83889  0.9910          |                  |        

. corrgram pearsZQ1c, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.1257  -0.1258   1.7394  0.1872         -|                 -|        
2        0.1514   0.1396   4.2871  0.1172          |-                 |-       
3        0.1329   0.1780    6.268  0.0993          |-                 |-       
4        0.0329   0.0470   6.3903  0.1718          |                  |        
5        0.0098  -0.0317   6.4014  0.2691          |                  |        
6       -0.0007  -0.0413   6.4015  0.3798          |                  |        

. corrgram pearsB0, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1        0.4437   0.4453   21.857  0.0000          |---               |---     
2        0.3774   0.2290   37.821  0.0000          |---               |-       
3        0.3241   0.1232   49.707  0.0000          |--                |        
4        0.2023  -0.0386   54.383  0.0000          |-                 |        
5        0.1080  -0.0727   55.727  0.0000          |                  |        
6        0.0290  -0.0754   55.825  0.0000          |                  |        

. corrgram pearsB1, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.1063  -0.1064   1.2434  0.2648          |                  |        
2        0.1559   0.1478   3.9422  0.1393          |-                 |-       
3        0.1463   0.1873   6.3437  0.0960          |-                 |-       
4        0.0734   0.0860    6.954  0.1383          |                  |        
5        0.0330  -0.0028   7.0782  0.2149          |                  |        
6       -0.0011  -0.0540   7.0783  0.3137          |                  |        

. corrgram pearsB2, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.0213  -0.0213   .04925  0.8244          |                  |        
2       -0.0186  -0.0192   .08724  0.9573          |                  |        
3        0.1110   0.1127   1.4574  0.6921          |                  |        
4        0.0419   0.0454   1.6544  0.7990          |                  |        
5        0.0021   0.0061   1.6549  0.8945          |                  |        
6       -0.0285  -0.0405   1.7478  0.9414          |                  |        

. corrgram pearsB3, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.0065  -0.0064   .00457  0.9461          |                  |        
2        0.0533   0.0545   .31495  0.8543          |                  |        
3        0.0209   0.0202   .36298  0.9478          |                  |        
4        0.0041   0.0008   .36488  0.9853          |                  |        
5       -0.0312  -0.0337    .4742  0.9930          |                  |        
6       -0.0646  -0.0648   .94791  0.9875          |                  |        

. 
. *** FIGURE 7.3: STRIKES PREDICTED FROM A DYNAMIC MODEL
. 
. graph twoway (line STRIKES MONTH, lwidth(medthick))                   ///
>   (line yhatB1 MONTH, lpattern(dash) lwidth(medthick)),               ///
>   scale(1.2) legend(ring(0) rows(2) pos(12) label(1 "Actual strikes") ///
>   label(2 "Predicted strikes")) ytitle("Strikes: actual and predicted") 

. graph export racd07fig3.eps, replace
(file racd07fig3.eps written in EPS format)

. graph export racd07fig3.wmf, replace
(file c:\acdbookrevision\stata_final_programs_2013\racd07fig3.wmf written in Windo
> ws Metafile format)

. 
. * Try Brannas model with rho1 varying with regressors
. nl (STRIKES = (1/(1 + exp(-{gamma1}-{gamma2}*OUTPUT)))*yL1 + ///
>   exp({beta1}+{beta2}*OUTPUT) ) if yL1 != ., initial(gamma1 0.1 gamma2 0.1) vce(
> robust)
(obs = 107)

Iteration 0:  residual SS =  1104.403
Iteration 1:  residual SS =  1079.552
Iteration 2:  residual SS =  1079.318
Iteration 3:  residual SS =  1079.318
Iteration 4:  residual SS =  1079.318
Iteration 5:  residual SS =  1079.318
Iteration 6:  residual SS =  1079.318
Iteration 7:  residual SS =  1079.318
Iteration 8:  residual SS =  1079.318

Nonlinear regression                                 Number of obs =       107
                                                     R-squared     =    0.7573
                                                     Adj R-squared =    0.7479
                                                     Root MSE      =    3.2371
                                                     Res. dev.     =  550.9572

------------------------------------------------------------------------------
             |               Robust
     STRIKES |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
     /gamma1 |   -.343444   .3943564    -0.87   0.386    -1.125557    .4386689
     /gamma2 |   11.92097   7.203911     1.65   0.101    -2.366285    26.20823
      /beta1 |   1.082671   .1690651     6.40   0.000     .7473699    1.417972
      /beta2 |  -.7354947   2.040532    -0.36   0.719    -4.782409     3.31142
------------------------------------------------------------------------------

. predict yhatB1z, yhat

. correlate STRIKES yhatB1z
(obs=107)

             |  STRIKES  yhatB1z
-------------+------------------
     STRIKES |   1.0000
     yhatB1z |   0.5321   1.0000


. predict resB1z, residual

. generate pearsB1z = resB3 / sqrt(yhatB1z)
(3 missing values generated)

. corrgram resB1z, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.1095  -0.1096   1.3188  0.2508          |                  |        
2        0.1286   0.1193   3.1557  0.2064          |-                 |        
3        0.1865   0.2231   7.0546  0.0702          |-                 |-       
4        0.0295   0.0538   7.1529  0.1280          |                  |        
5        0.0550   0.0095   7.4985  0.1861          |                  |        
6       -0.0070  -0.0549   7.5042  0.2767          |                  |        

. corrgram pearsB1z, lags(6)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.0018  -0.0016   .00033  0.9855          |                  |        
2        0.0423   0.0432   .19565  0.9068          |                  |        
3        0.0220   0.0213   .24918  0.9693          |                  |        
4        0.0217   0.0198   .30173  0.9897          |                  |        
5       -0.0628  -0.0660   .74484  0.9804          |                  |        
6       -0.0868  -0.0890   1.5993  0.9526          |                  |        

. * The range of values of rho1
. generate rho1 = 1/(1 + exp(-_b[/gamma1]-_b[/gamma2]*OUTPUT)) 

. summarize rho1

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
        rho1 |       108    .4141168     .143774   .1179588   .6629071

. 
. **********  7.11.2 DYNAMIC REGRESSION FOR STOCK TRADES DATA
. 
. use racd07data2stocktrades.dta, clear

. 
. describe

Contains data from racd07data2stocktrades.dta
  obs:         2,925                          
 vars:            10                          17 Mar 2012 14:01
 size:        81,900                          
----------------------------------------------------------------------------------
              storage  display     value
variable name   type   format      label      variable label
----------------------------------------------------------------------------------
t               float  %9.0g                  Time in five-minute segments
day             float  %9.0g                  Trading day: 1-39
segment         byte   %8.0g                  Five-miute segment of day: 1-75
glt             byte   %8.0g                  Number of Trades: Glatfelter Company
ede             byte   %8.0g                  Number of Trades: ede
wpp             byte   %8.0g                  Number of Trades: wpp
x1              float  %9.0g                  cos(2*pi*t/75)
x2              float  %9.0g                  sin(2*pi*t/75)
x3              float  %9.0g                  cos(4*pi*t/75)
x4              float  %9.0g                  sin(4*pi*t/75)
----------------------------------------------------------------------------------
Sorted by:  t

. summarize

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
           t |      2925        1463    844.5191          1       2925
         day |      2925          20    11.25655          1         39
     segment |      2925          38    21.65241          1         75
         glt |      2925    5.663248    3.899617          0         34
         ede |      2925    3.313846    3.034564          0         25
-------------+--------------------------------------------------------
         wpp |      2925    8.111453    5.961392          0         43
          x1 |      2925   -6.36e-09    .7072277  -.9991229          1
          x2 |      2925   -7.26e-17    .7072277  -.9997807   .9997807
          x3 |      2925   -6.36e-09    .7072277  -.9991229          1
          x4 |      2925   -1.45e-16    .7072277  -.9997807   .9997807

. tabulate glt

  Number of |
    Trades: |
 Glatfelter |
    Company |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |         81        2.77        2.77
          1 |        221        7.56       10.32
          2 |        303       10.36       20.68
          3 |        356       12.17       32.85
          4 |        340       11.62       44.48
          5 |        345       11.79       56.27
          6 |        286        9.78       66.05
          7 |        231        7.90       73.95
          8 |        195        6.67       80.62
          9 |        143        4.89       85.50
         10 |        113        3.86       89.37
         11 |         90        3.08       92.44
         12 |         55        1.88       94.32
         13 |         45        1.54       95.86
         14 |         37        1.26       97.13
         15 |         22        0.75       97.88
         16 |         15        0.51       98.39
         17 |         17        0.58       98.97
         18 |          5        0.17       99.15
         19 |          8        0.27       99.42
         20 |          3        0.10       99.52
         21 |          2        0.07       99.59
         22 |          2        0.07       99.66
         23 |          1        0.03       99.69
         25 |          2        0.07       99.76
         26 |          2        0.07       99.83
         27 |          2        0.07       99.90
         30 |          1        0.03       99.93
         32 |          1        0.03       99.97
         34 |          1        0.03      100.00
------------+-----------------------------------
      Total |      2,925      100.00

. 
. *** FIGURE 7.4: HISTOGRAM AND TIME SERIES OF NUMBER OF TRADES
. 
. histogram glt, scale(1.9) saving(histogram, replace) 
(bin=34, start=0, width=1)
(file histogram.gph saved)

. line glt t if t < 76, scale(1.9) saving(timeseries, replace)
(file timeseries.gph saved)

. graph combine histogram.gph timeseries.gph, ysize(3) xsize(6) iscale(0.7)

. graph export racd07fig4.wmf, replace
(file c:\acdbookrevision\stata_final_programs_2013\racd07fig4.wmf written in Windo
> ws Metafile format)

. graph export racd07fig4.eps, replace
(file racd07fig4.eps written in EPS format)

. 
. * There is considerable autocorrelation
. corrgram glt, lags(100)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1        0.3265   0.3270   312.04  0.0000          |--                |--      
2        0.2738   0.1874   531.67  0.0000          |--                |-       
3        0.2335   0.1162   691.43  0.0000          |-                 |        
4        0.2067   0.0819    816.7  0.0000          |-                 |        
5        0.1889   0.0642   921.27  0.0000          |-                 |        
6        0.2068   0.0904   1046.7  0.0000          |-                 |        
7        0.1642   0.0274   1125.9  0.0000          |-                 |        
8        0.1353   0.0068   1179.6  0.0000          |-                 |        
9        0.1564   0.0518   1251.4  0.0000          |-                 |        
10       0.1353   0.0216   1305.2  0.0000          |-                 |        
11       0.1368   0.0305   1360.2  0.0000          |-                 |        
12       0.1370   0.0304   1415.3  0.0000          |-                 |        
13       0.1009  -0.0106   1445.2  0.0000          |                  |        
14       0.0999   0.0085   1474.6  0.0000          |                  |        
15       0.1077   0.0217   1508.7  0.0000          |                  |        
16       0.0906   0.0019   1532.9  0.0000          |                  |        
17       0.0725  -0.0113   1548.4  0.0000          |                  |        
18       0.0900   0.0212   1572.2  0.0000          |                  |        
19       0.0837   0.0154   1592.9  0.0000          |                  |        
20       0.0715  -0.0001   1607.9  0.0000          |                  |        
21       0.0528  -0.0196   1616.2  0.0000          |                  |        
22       0.0510  -0.0043   1623.8  0.0000          |                  |        
23       0.0381  -0.0116   1628.1  0.0000          |                  |        
24       0.0287  -0.0174   1630.5  0.0000          |                  |        
25       0.0223  -0.0137     1632  0.0000          |                  |        
26       0.0294   0.0051   1634.6  0.0000          |                  |        
27       0.0111  -0.0169   1634.9  0.0000          |                  |        
28       0.0073  -0.0116   1635.1  0.0000          |                  |        
29       0.0001  -0.0136   1635.1  0.0000          |                  |        
30      -0.0072  -0.0157   1635.2  0.0000          |                  |        
31      -0.0007   0.0002   1635.2  0.0000          |                  |        
32      -0.0336  -0.0395   1638.6  0.0000          |                  |        
33      -0.0243  -0.0091   1640.3  0.0000          |                  |        
34      -0.0089   0.0130   1640.6  0.0000          |                  |        
35      -0.0246  -0.0120   1642.4  0.0000          |                  |        
36      -0.0463  -0.0316   1648.7  0.0000          |                  |        
37      -0.0474  -0.0225   1655.4  0.0000          |                  |        
38      -0.0483  -0.0129   1662.3  0.0000          |                  |        
39      -0.0402   0.0025   1667.1  0.0000          |                  |        
40      -0.0268   0.0107   1669.2  0.0000          |                  |        
41      -0.0076   0.0308   1669.4  0.0000          |                  |        
42      -0.0371  -0.0159   1673.5  0.0000          |                  |        
43      -0.0108   0.0240   1673.8  0.0000          |                  |        
44      -0.0252  -0.0034   1675.7  0.0000          |                  |        
45      -0.0165   0.0073   1676.5  0.0000          |                  |        
46      -0.0238  -0.0062   1678.2  0.0000          |                  |        
47      -0.0086   0.0181   1678.4  0.0000          |                  |        
48      -0.0050   0.0191   1678.5  0.0000          |                  |        
49      -0.0224  -0.0157     1680  0.0000          |                  |        
50      -0.0163   0.0002   1680.8  0.0000          |                  |        
51       0.0091   0.0343     1681  0.0000          |                  |        
52       0.0210   0.0292   1682.4  0.0000          |                  |        
53       0.0157   0.0090   1683.1  0.0000          |                  |        
54       0.0168   0.0088   1683.9  0.0000          |                  |        
55       0.0335   0.0306   1687.3  0.0000          |                  |        
56       0.0408   0.0275   1692.3  0.0000          |                  |        
57       0.0325   0.0023   1695.4  0.0000          |                  |        
58       0.0397   0.0142   1700.1  0.0000          |                  |        
59       0.0349   0.0018   1703.7  0.0000          |                  |        
60       0.0453   0.0158   1709.9  0.0000          |                  |        
61       0.0219  -0.0210   1711.3  0.0000          |                  |        
62       0.0301  -0.0026     1714  0.0000          |                  |        
63       0.0452   0.0176   1720.1  0.0000          |                  |        
64       0.0573   0.0262     1730  0.0000          |                  |        
65       0.0279  -0.0218   1732.3  0.0000          |                  |        
66       0.0384  -0.0007   1736.7  0.0000          |                  |        
67       0.0367  -0.0019   1740.8  0.0000          |                  |        
68       0.0636   0.0361   1752.9  0.0000          |                  |        
69       0.0838   0.0409     1774  0.0000          |                  |        
70       0.0901   0.0309   1798.3  0.0000          |                  |        
71       0.0867   0.0207   1820.8  0.0000          |                  |        
72       0.0967   0.0313   1848.9  0.0000          |                  |        
73       0.0868   0.0113   1871.5  0.0000          |                  |        
74       0.0896   0.0077   1895.6  0.0000          |                  |        
75       0.1304   0.0592   1946.7  0.0000          |-                 |        
76       0.0840  -0.0139   1967.9  0.0000          |                  |        
77       0.0840   0.0026   1989.1  0.0000          |                  |        
78       0.0649  -0.0243   2001.8  0.0000          |                  |        
79       0.0575  -0.0156   2011.7  0.0000          |                  |        
80       0.0535  -0.0084   2020.3  0.0000          |                  |        
81       0.0470  -0.0194     2027  0.0000          |                  |        
82       0.0355  -0.0237   2030.8  0.0000          |                  |        
83       0.0328  -0.0088     2034  0.0000          |                  |        
84       0.0315  -0.0098     2037  0.0000          |                  |        
85       0.0058  -0.0316   2037.1  0.0000          |                  |        
86       0.0478   0.0263     2044  0.0000          |                  |        
87       0.0339   0.0014   2047.5  0.0000          |                  |        
88      -0.0062  -0.0448   2047.6  0.0000          |                  |        
89       0.0029  -0.0140   2047.6  0.0000          |                  |        
90       0.0321   0.0287   2050.7  0.0000          |                  |        
91       0.0149  -0.0007   2051.4  0.0000          |                  |        
92       0.0148   0.0011     2052  0.0000          |                  |        
93      -0.0102  -0.0307   2052.4  0.0000          |                  |        
94      -0.0365  -0.0419   2056.4  0.0000          |                  |        
95      -0.0239  -0.0133   2058.1  0.0000          |                  |        
96      -0.0219  -0.0053   2059.6  0.0000          |                  |        
97      -0.0059   0.0179   2059.7  0.0000          |                  |        
98       0.0036   0.0212   2059.7  0.0000          |                  |        
99      -0.0233  -0.0193   2061.4  0.0000          |                  |        
100     -0.0267  -0.0015   2063.5  0.0000          |                  |        

. 
. * Poisson intercept-only
. poisson glt, vce(robust)

Iteration 0:   log pseudolikelihood = -8618.1094  
Iteration 1:   log pseudolikelihood = -8618.1094  

Poisson regression                                Number of obs   =       2925
                                                  Wald chi2(0)    =          .
                                                  Prob > chi2     =          .
Log pseudolikelihood = -8618.1094                 Pseudo R2       =     0.0000

------------------------------------------------------------------------------
             |               Robust
         glt |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _cons |   1.733998   .0127319   136.19   0.000     1.709043    1.758952
------------------------------------------------------------------------------

. estimates store INTONLY

. 
. * Poisson with just trigonometric terms
. poisson glt x1 x2 x3 x4, vce(robust)

Iteration 0:   log pseudolikelihood = -8374.4646  
Iteration 1:   log pseudolikelihood = -8374.4645  

Poisson regression                                Number of obs   =       2925
                                                  Wald chi2(4)    =     188.44
                                                  Prob > chi2     =     0.0000
Log pseudolikelihood = -8374.4645                 Pseudo R2       =     0.0283

------------------------------------------------------------------------------
             |               Robust
         glt |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          x1 |   .2417415   .0176962    13.66   0.000     .2070575    .2764256
          x2 |   .0210718   .0176364     1.19   0.232     -.013495    .0556385
          x3 |  -.0201147   .0178163    -1.13   0.259    -.0550341    .0148046
          x4 |   .0318601   .0172686     1.84   0.065    -.0019856    .0657059
       _cons |    1.71908   .0124839   137.70   0.000     1.694612    1.743548
------------------------------------------------------------------------------

. estimates store STATIC

. test x1 x2 x3 x4

 ( 1)  [glt]x1 = 0
 ( 2)  [glt]x2 = 0
 ( 3)  [glt]x3 = 0
 ( 4)  [glt]x4 = 0

           chi2(  4) =  188.44
         Prob > chi2 =    0.0000

. predict yhatP0, n

. predict resP0, score   

. generate pearsP0 = resP0 / sqrt(yhatP0)

. 
. tsline yhatP0 in 1/150

. 
. * Poisson with one lag of Pearson residual
. poisson glt x1 x2 x3 x4 L.pearsP0, vce(robust)

Iteration 0:   log pseudolikelihood = -8101.0375  
Iteration 1:   log pseudolikelihood = -8101.0337  
Iteration 2:   log pseudolikelihood = -8101.0337  

Poisson regression                                Number of obs   =       2924
                                                  Wald chi2(5)    =     425.45
                                                  Prob > chi2     =     0.0000
Log pseudolikelihood = -8101.0337                 Pseudo R2       =     0.0597

------------------------------------------------------------------------------
             |               Robust
         glt |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          x1 |   .2433316    .017018    14.30   0.000      .209977    .2766863
          x2 |    .016494   .0168764     0.98   0.328    -.0165832    .0495712
          x3 |  -.0186755   .0169773    -1.10   0.271    -.0519503    .0145993
          x4 |   .0303135    .016718     1.81   0.070    -.0024531    .0630802
             |
     pearsP0 |
         L1. |   .1046014   .0070295    14.88   0.000     .0908238     .118379
             |
       _cons |   1.704473    .011964   142.47   0.000     1.681024    1.727922
------------------------------------------------------------------------------

. estimates store P1

. predict yhatP1, n
(1 missing value generated)

. predict resP1, score   
(1 missing values generated)

. generate pearsP1 = resP1 / sqrt(yhatP1)
(1 missing value generated)

. 
. * Poisson with two lags of Pearson residual
. poisson glt x1 x2 x3 x4 L.pearsP0 L2.pearsP0, vce(robust)

Iteration 0:   log pseudolikelihood = -8018.8298  
Iteration 1:   log pseudolikelihood = -8018.8244  
Iteration 2:   log pseudolikelihood = -8018.8244  

Poisson regression                                Number of obs   =       2923
                                                  Wald chi2(6)    =     503.15
                                                  Prob > chi2     =     0.0000
Log pseudolikelihood = -8018.8244                 Pseudo R2       =     0.0690

------------------------------------------------------------------------------
             |               Robust
         glt |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          x1 |   .2446722   .0168409    14.53   0.000     .2116646    .2776797
          x2 |   .0137407   .0166444     0.83   0.409    -.0188816    .0463631
          x3 |  -.0181574   .0166718    -1.09   0.276    -.0508335    .0145187
          x4 |   .0305194   .0166304     1.84   0.066    -.0020756    .0631143
             |
     pearsP0 |
         L1. |   .0869893   .0074032    11.75   0.000     .0724794    .1014992
         L2. |    .060331   .0070818     8.52   0.000     .0464509    .0742112
             |
       _cons |   1.700158   .0118255   143.77   0.000      1.67698    1.723336
------------------------------------------------------------------------------

. estimates store P2

. predict yhatP2, n
(2 missing values generated)

. predict resP2, score   
(2 missing values generated)

. generate pearsP2 = resP2 / sqrt(yhatP2)
(2 missing values generated)

. 
. * Poisson with three lags of Pearson residual
. poisson glt x1 x2 x3 x4 L.pearsP0 L2.pearsP0 L3.pearsP0, vce(robust)

Iteration 0:   log pseudolikelihood = -7987.4088  
Iteration 1:   log pseudolikelihood = -7987.4036  
Iteration 2:   log pseudolikelihood = -7987.4036  

Poisson regression                                Number of obs   =       2922
                                                  Wald chi2(7)    =     524.02
                                                  Prob > chi2     =     0.0000
Log pseudolikelihood = -7987.4036                 Pseudo R2       =     0.0722

------------------------------------------------------------------------------
             |               Robust
         glt |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          x1 |   .2458214   .0168182    14.62   0.000     .2128583    .2787844
          x2 |   .0125986   .0165162     0.76   0.446    -.0197727    .0449698
          x3 |  -.0175558   .0165505    -1.06   0.289    -.0499942    .0148825
          x4 |   .0311392   .0166062     1.88   0.061    -.0014084    .0636868
             |
     pearsP0 |
         L1. |   .0812965   .0076957    10.56   0.000     .0662133    .0963798
         L2. |   .0514478   .0073036     7.04   0.000      .037133    .0657626
         L3. |   .0364929   .0077975     4.68   0.000     .0212101    .0517757
             |
       _cons |   1.698822   .0117915   144.07   0.000     1.675711    1.721933
------------------------------------------------------------------------------

. estimates store P3

. predict yhatP3, n
(3 missing values generated)

. predict resP3, score   
(3 missing values generated)

. generate pearsP3 = resP3 / sqrt(yhatP3)
(3 missing values generated)

. 
. * Poisson with Zeger-Qaqish one lag of y as regressor
. generate gltstar = glt 

. replace gltstar = 0.5 if gltstar == 0
(81 real changes made)

. generate lngltstar = ln(gltstar)

. summarize gltstar glt

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     gltstar |      2925    5.677094    3.880317         .5         34
         glt |      2925    5.663248    3.899617          0         34

. poisson glt x1 x2 x3 x4 L.lngltstar, vce(robust)

Iteration 0:   log pseudolikelihood = -8127.2513  
Iteration 1:   log pseudolikelihood =  -8127.251  

Poisson regression                                Number of obs   =       2924
                                                  Wald chi2(5)    =     371.82
                                                  Prob > chi2     =     0.0000
Log pseudolikelihood =  -8127.251                 Pseudo R2       =     0.0566

------------------------------------------------------------------------------
             |               Robust
         glt |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
          x1 |   .1750245   .0177152     9.88   0.000     .1403033    .2097457
          x2 |   .0176664   .0169373     1.04   0.297    -.0155301    .0508628
          x3 |  -.0122143   .0171045    -0.71   0.475    -.0457385      .02131
          x4 |   .0272044   .0167066     1.63   0.103    -.0055399    .0599487
             |
   lngltstar |
         L1. |   .2388235   .0180476    13.23   0.000     .2034508    .2741962
             |
       _cons |   1.350856    .030462    44.35   0.000     1.291152     1.41056
------------------------------------------------------------------------------

. estimates store ZQ1

. predict yhatZQ1, n
(1 missing value generated)

. predict resZQ1, score
(1 missing values generated)

. generate pearsZQ1 = resZQ1 / sqrt(yhatZQ1)
(1 missing value generated)

. 
. * Brannas Conditional NL of INAR(1) model
. generate one = 1

. global XLIST x1 x2 x3 x4

. generate gltL1 = L.glt
(1 missing value generated)

. 
. * Compare NLS of static model with Poisson of static model earlier
. nl (glt = exp({xb: $XLIST one})), vce(robust)
(obs = 2925)

Iteration 0:  residual SS =  58170.32
Iteration 1:  residual SS =  45649.64
Iteration 2:  residual SS =  41771.62
Iteration 3:  residual SS =  41741.62
Iteration 4:  residual SS =  41741.61
Iteration 5:  residual SS =  41741.61
Iteration 6:  residual SS =  41741.61
Iteration 7:  residual SS =  41741.61

Nonlinear regression                                 Number of obs =      2925
                                                     R-squared     =    0.6981
                                                     Adj R-squared =    0.6976
                                                     Root MSE      =  3.780883
                                                     Res. dev.     =  16076.04

------------------------------------------------------------------------------
             |               Robust
         glt |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      /xb_x1 |   .2402848   .0176734    13.60   0.000     .2056312    .2749385
      /xb_x2 |   .0217964   .0177241     1.23   0.219    -.0129566    .0565494
      /xb_x3 |  -.0166151   .0181831    -0.91   0.361    -.0522682    .0190379
      /xb_x4 |   .0269607    .017231     1.56   0.118    -.0068255    .0607469
     /xb_one |   1.719435   .0124931   137.63   0.000     1.694939    1.743931
------------------------------------------------------------------------------

. estimates store B0

. predict yhatB0, yhat

. predict resB0, residual

. generate pearsB0 = resB0 / sqrt(yhatB0) 

. 
. * Brannas Conditional NL of INAR(1) model
. nl (glt = {rho1}*gltL1 + exp({xb: $XLIST one}) ) if gltL1 != ., initial(rho1 0.3
> ) vce(robust)
(obs = 2924)

Iteration 0:  residual SS =   43745.7
Iteration 1:  residual SS =  38466.26
Iteration 2:  residual SS =  38372.99
Iteration 3:  residual SS =  38372.84
Iteration 4:  residual SS =  38372.84
Iteration 5:  residual SS =  38372.84
Iteration 6:  residual SS =  38372.84
Iteration 7:  residual SS =  38372.84

Nonlinear regression                                 Number of obs =      2924
                                                     R-squared     =    0.7225
                                                     Adj R-squared =    0.7219
                                                     Root MSE      =  3.626347
                                                     Res. dev.     =  15825.49

------------------------------------------------------------------------------
             |               Robust
         glt |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       /rho1 |   .2831876   .0216475    13.08   0.000     .2407417    .3256335
      /xb_x1 |   .2422538   .0236093    10.26   0.000     .1959613    .2885463
      /xb_x2 |   .0138979   .0236468     0.59   0.557    -.0324681    .0602639
      /xb_x3 |  -.0136374   .0243204    -0.56   0.575    -.0613243    .0340496
      /xb_x4 |   .0282694   .0230573     1.23   0.220    -.0169409    .0734797
     /xb_one |   1.386919   .0307663    45.08   0.000     1.326593    1.447245
------------------------------------------------------------------------------

. estimates store B1

. predict yhatB1, yhat

. predict resB1, residual

. generate pearsB1 = resB1 / sqrt(yhatB1) 
(1 missing value generated)

. 
. *** TABLE 7.6 STOCK TRADES: STATIC AND DYNAMIC MODEL ESTIMATES
. 
. estimates table INTONLY STATIC ZQ1 P1 P3 , b(%9.3f) se 

--------------------------------------------------------------------------
    Variable |  INTONLY     STATIC        ZQ1         P1          P3      
-------------+------------------------------------------------------------
          x1 |                 0.242       0.175       0.243       0.246  
             |                 0.018       0.018       0.017       0.017  
          x2 |                 0.021       0.018       0.016       0.013  
             |                 0.018       0.017       0.017       0.017  
          x3 |                -0.020      -0.012      -0.019      -0.018  
             |                 0.018       0.017       0.017       0.017  
          x4 |                 0.032       0.027       0.030       0.031  
             |                 0.017       0.017       0.017       0.017  
             |
   lngltstar |
         L1. |                             0.239                          
             |                             0.018                          
             |
     pearsP0 |
         L1. |                                         0.105       0.081  
             |                                         0.007       0.008  
         L2. |                                                     0.051  
             |                                                     0.007  
         L3. |                                                     0.036  
             |                                                     0.008  
             |
       _cons |     1.734       1.719       1.351       1.704       1.699  
             |     0.013       0.012       0.030       0.012       0.012  
--------------------------------------------------------------------------
                                                              legend: b/se

. 
. estimates table B1, b(%9.3f) se 

--------------------------
    Variable |    B1      
-------------+------------
rho1         |
       _cons |     0.283  
             |     0.022  
-------------+------------
xb_x1        |
       _cons |     0.242  
             |     0.024  
-------------+------------
xb_x2        |
       _cons |     0.014  
             |     0.024  
-------------+------------
xb_x3        |
       _cons |    -0.014  
             |     0.024  
-------------+------------
xb_x4        |
       _cons |     0.028  
             |     0.023  
-------------+------------
xb_one       |
       _cons |     1.387  
             |     0.031  
--------------------------
              legend: b/se

. 
. * Correlations
. correlate glt yhatP0 yhatZQ1 yhatB1 yhatP1 yhatP3
(obs=2922)

             |      glt   yhatP0  yhatZQ1   yhatB1   yhatP1   yhatP3
-------------+------------------------------------------------------
         glt |   1.0000
      yhatP0 |   0.2492   1.0000
     yhatZQ1 |   0.3568   0.7111   1.0000
      yhatB1 |   0.3700   0.6700   0.9680   1.0000
      yhatP1 |   0.3636   0.6610   0.9312   0.9884   1.0000
      yhatP3 |   0.3988   0.6008   0.8455   0.8947   0.9014   1.0000


. summarize glt yhatP0 yhatZQ1 yhatB1 yhatP1 yhatP3

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
         glt |      2925    5.663248    3.899617          0         34
      yhatP0 |      2925    5.663248    .9684182   4.282254   7.090174
     yhatZQ1 |      2924    5.664501     1.36475   2.705509   10.03784
      yhatB1 |      2924    5.664942    1.440391   3.089712   14.21593
      yhatP1 |      2924    5.664501    1.467732    3.39707   19.37627
-------------+--------------------------------------------------------
      yhatP3 |      2922    5.667009    1.621063   2.946965   19.90041

. 
. * For Ljung-Box test use the Pearson residuals
. corrgram glt, lags(10)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1        0.3265   0.3270   312.04  0.0000          |--                |--      
2        0.2738   0.1874   531.67  0.0000          |--                |-       
3        0.2335   0.1162   691.43  0.0000          |-                 |        
4        0.2067   0.0819    816.7  0.0000          |-                 |        
5        0.1889   0.0642   921.27  0.0000          |-                 |        
6        0.2068   0.0904   1046.7  0.0000          |-                 |        
7        0.1642   0.0274   1125.9  0.0000          |-                 |        
8        0.1353   0.0068   1179.6  0.0000          |-                 |        
9        0.1564   0.0518   1251.4  0.0000          |-                 |        
10       0.1353   0.0216   1305.2  0.0000          |-                 |        

. corrgram pearsP0, lags(10)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1        0.2849   0.2851    237.6  0.0000          |--                |--      
2        0.2297   0.1619   392.19  0.0000          |-                 |-       
3        0.1824   0.0915   489.71  0.0000          |-                 |        
4        0.1568   0.0655   561.76  0.0000          |-                 |        
5        0.1422   0.0546   621.06  0.0000          |-                 |        
6        0.1663   0.0861    702.2  0.0000          |-                 |        
7        0.1298   0.0311   751.65  0.0000          |-                 |        
8        0.1008   0.0067   781.46  0.0000          |                  |        
9        0.1254   0.0519   827.62  0.0000          |-                 |        
10       0.1071   0.0245    861.3  0.0000          |                  |        

. corrgram pearsZQ1, lags(10)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.0131  -0.0131   .50484  0.4774          |                  |        
2        0.1333   0.1333   52.503  0.0000          |-                 |-       
3        0.1019   0.1072   82.909  0.0000          |                  |        
4        0.0873   0.0758   105.26  0.0000          |                  |        
5        0.0702   0.0489   119.69  0.0000          |                  |        
6        0.1079   0.0834   153.81  0.0000          |                  |        
7        0.0740   0.0521    169.9  0.0000          |                  |        
8        0.0420   0.0066   175.06  0.0000          |                  |        
9        0.0838   0.0465   195.69  0.0000          |                  |        
10       0.0532   0.0258   204.01  0.0000          |                  |        

. corrgram pearsB1, lags(10)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.0447  -0.0448   5.8469  0.0156          |                  |        
2        0.1249   0.1233   51.523  0.0000          |                  |        
3        0.0956   0.1080   78.274  0.0000          |                  |        
4        0.0826   0.0790   98.266  0.0000          |                  |        
5        0.0674   0.0530   111.59  0.0000          |                  |        
6        0.1110   0.0920   147.69  0.0000          |                  |        
7        0.0741   0.0598    163.8  0.0000          |                  |        
8        0.0392   0.0080    168.3  0.0000          |                  |        
9        0.0836   0.0466   188.82  0.0000          |                  |        
10       0.0526   0.0279   196.95  0.0000          |                  |        

. corrgram pearsP1, lags(10)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1       -0.0307  -0.0308   2.7613  0.0966          |                  |        
2        0.1293   0.1287   51.707  0.0000          |-                 |-       
3        0.1008   0.1103   81.485  0.0000          |                  |        
4        0.0881   0.0812   104.21  0.0000          |                  |        
5        0.0720   0.0544   119.42  0.0000          |                  |        
6        0.1179   0.0959   160.19  0.0000          |                  |        
7        0.0795   0.0614   178.73  0.0000          |                  |        
8        0.0449   0.0097   184.66  0.0000          |                  |        
9        0.0882   0.0480   207.48  0.0000          |                  |        
10       0.0593   0.0304   217.81  0.0000          |                  |        

. corrgram pearsP3, lags(10)

                                          -1       0       1 -1       0       1
 LAG       AC       PAC      Q     Prob>Q  [Autocorrelation]  [Partial Autocor]
-------------------------------------------------------------------------------
1        0.0089   0.0089   .23171  0.6303          |                  |        
2       -0.0013  -0.0014   .23683  0.8883          |                  |        
3       -0.0244  -0.0244   1.9735  0.5779          |                  |        
4        0.0355   0.0360   5.6566  0.2263          |                  |        
5        0.0384   0.0378   9.9775  0.0759          |                  |        
6        0.0863   0.0856   31.811  0.0000          |                  |        
7        0.0507   0.0521   39.358  0.0000          |                  |        
8        0.0144   0.0152   39.963  0.0000          |                  |        
9        0.0553   0.0580   48.923  0.0000          |                  |        
10       0.0384   0.0341    53.24  0.0000          |                  |        

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

. exit, clear
