------------------------------------------------------------------------------------------------ name: log: c:\Users\ccameron\Dropbox\Desktop\Imbook\courses\2019_canada\canada03_panel\canada2 > 019_panel.txt log type: text opened on: 8 May 2019, 21:33:41 . . ********** OVERVIEW OF canada2019_panel.do ********** . . * STATA Program to demonstrate Cound Data Regression Models . * Based on mus17p1cnt.do . * A. Colin Cameron and Pravin K. Trivedi (2009) . * "Microeconometrics using Stata", Stata Press . . * 1A. COUNT REGRESSION: BASIC CROSS-SECTION . * 1B. COUNT REGRESSION: INFERENCE (STANDARD ERRORS AND BOOTSTRAP) . * 2: COUNT REGRESSION: EXTRAS (TRUNCATED/CENSORED, HURDLE, ZERO-INFLATED, . * FINITE MIXTURE, ENDOGENOUS) . * 3: COUNT REGRESSION: BASIC PANEL . . * To run you need files . * mus18data.dta . * racd09data.dta . * in your directory . . ********** SETUP ********** . . set more off . version 15 . clear all . set mem 10m set memory ignored. Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically. . set scheme s1mono /* Graphics scheme */ . . *********** 3: PANEL COUNT REGRESSION . . * Describe dependent variables and regressors . use mus18data.dta, clear . describe mdu lcoins ndisease female age lfam child id year storage display value variable name type format label variable label ------------------------------------------------------------------------------------------------ mdu float %9.0g number face-to-fact md visits lcoins float %9.0g log(coinsurance+1) ndisease float %9.0g count of chronic diseases -- ba female float %9.0g female age float %9.0g age that year lfam float %9.0g log of family size child float %9.0g child id float %9.0g person id, leading digit is sit year float %9.0g study year . . * Summarize dependent variables and regressors . summarize mdu lcoins ndisease female age lfam child id year Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- mdu | 20,186 2.860696 4.504765 0 77 lcoins | 20,186 2.383588 2.041713 0 4.564348 ndisease | 20,186 11.2445 6.741647 0 58.6 female | 20,186 .5169424 .4997252 0 1 age | 20,186 25.71844 16.76759 0 64.27515 -------------+--------------------------------------------------------- lfam | 20,186 1.248404 .5390681 0 2.639057 child | 20,186 .4014168 .4901972 0 1 id | 20,186 357971.2 180885.6 125024 632167 year | 20,186 2.420044 1.217237 1 5 . . *** PANEL DATA SUMMARY . . * Panel description of dataset . xtset id year panel variable: id (unbalanced) time variable: year, 1 to 5, but with gaps delta: 1 unit . xtdescribe id: 125024, 125025, ..., 632167 n = 5908 year: 1, 2, ..., 5 T = 5 Delta(year) = 1 unit Span(year) = 5 periods (id*year uniquely identifies each observation) Distribution of T_i: min 5% 25% 50% 75% 95% max 1 2 3 3 5 5 5 Freq. Percent Cum. | Pattern ---------------------------+--------- 3710 62.80 62.80 | 111.. 1584 26.81 89.61 | 11111 156 2.64 92.25 | 1.... 147 2.49 94.74 | 11... 79 1.34 96.07 | ..1.. 66 1.12 97.19 | .11.. 33 0.56 97.75 | ..111 33 0.56 98.31 | .1111 29 0.49 98.80 | ...11 71 1.20 100.00 | (other patterns) ---------------------------+--------- 5908 100.00 | XXXXX . . * Panel summary of dependent variable . xtsum mdu Variable | Mean Std. Dev. Min Max | Observations -----------------+--------------------------------------------+---------------- mdu overall | 2.860696 4.504765 0 77 | N = 20186 between | 3.785971 0 63.33333 | n = 5908 within | 2.575881 -34.47264 40.0607 | T-bar = 3.41672 . . * Year-to-year transitions in doctor visits . generate mdushort = mdu . replace mdushort = 4 if mdu >= 4 (4,039 real changes made) . xttrans mdushort | mdushort mdushort | 0 1 2 3 4 | Total -----------+-------------------------------------------------------+---------- 0 | 58.87 19.61 9.21 4.88 7.42 | 100.00 1 | 33.16 24.95 17.58 10.14 14.16 | 100.00 2 | 23.55 24.26 17.90 12.10 22.19 | 100.00 3 | 17.80 20.74 18.55 12.14 30.77 | 100.00 4 | 8.79 11.72 12.32 11.93 55.23 | 100.00 -----------+-------------------------------------------------------+---------- Total | 31.81 19.27 13.73 9.46 25.73 | 100.00 . corr mdu L.mdu (obs=14,266) | L. | mdu mdu -------------+------------------ mdu | --. | 1.0000 L1. | 0.6184 1.0000 . . * Simple time-series plot for first 20 individuals (= first 85 obs) . quietly xtline mdu if _n<=85, overlay legend(off) . graph export countfig31panelplot.wmf, replace (file c:\Users\ccameron\Dropbox\Desktop\Imbook\courses\2019_canada\canada03_panel\countfig31pane > lplot.wmf written in Windows Metafile format) . . * Autocorrelations - not the best way . sort id year . corr mdu L.mdu L2.mdu L3.mdu (obs=3,230) | L. L2. L3. | mdu mdu mdu mdu -------------+------------------------------------ mdu | --. | 1.0000 L1. | 0.6767 1.0000 L2. | 0.4974 0.6289 1.0000 L3. | 0.3714 0.4603 0.5994 1.0000 . . * Autocorrelations using all available data . pwcorr mdu L.mdu L2.mdu L3.mdu L4.mdu | mdu L.mdu L2.mdu L3.mdu L4.mdu -------------+--------------------------------------------- mdu | 1.0000 L.mdu | 0.6184 1.0000 L2.mdu | 0.4744 0.6029 1.0000 L3.mdu | 0.3714 0.4602 0.5995 1.0000 L4.mdu | 0.3820 0.3702 0.5054 0.6100 1.0000 . . *** 3. PANEL POISSON: POOLED AND POPULATION AVERAGED . . * Pooled Poisson estimator with cluster-robust standard errors . poisson mdu lcoins ndisease female age lfam child, vce(cluster id) Iteration 0: log pseudolikelihood = -62580.248 Iteration 1: log pseudolikelihood = -62579.401 Iteration 2: log pseudolikelihood = -62579.401 Poisson regression Number of obs = 20,186 Wald chi2(6) = 476.93 Prob > chi2 = 0.0000 Log pseudolikelihood = -62579.401 Pseudo R2 = 0.0609 (Std. Err. adjusted for 5,908 clusters in id) ------------------------------------------------------------------------------ | Robust mdu | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- lcoins | -.0808023 .0080013 -10.10 0.000 -.0964846 -.0651199 ndisease | .0339334 .0026024 13.04 0.000 .0288328 .039034 female | .1717862 .0342551 5.01 0.000 .1046473 .2389251 age | .0040585 .0016891 2.40 0.016 .000748 .0073691 lfam | -.1481981 .0323434 -4.58 0.000 -.21159 -.0848062 child | .1030453 .0506901 2.03 0.042 .0036944 .2023961 _cons | .748789 .0785738 9.53 0.000 .5947872 .9027907 ------------------------------------------------------------------------------ . . * Without cluster-robust . poisson mdu lcoins ndisease female age lfam child Iteration 0: log likelihood = -62580.248 Iteration 1: log likelihood = -62579.401 Iteration 2: log likelihood = -62579.401 Poisson regression Number of obs = 20,186 LR chi2(6) = 8122.52 Prob > chi2 = 0.0000 Log likelihood = -62579.401 Pseudo R2 = 0.0609 ------------------------------------------------------------------------------ mdu | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- lcoins | -.0808023 .0020358 -39.69 0.000 -.0847924 -.0768121 ndisease | .0339334 .0005581 60.80 0.000 .0328395 .0350273 female | .1717862 .0086984 19.75 0.000 .1547376 .1888348 age | .0040585 .0004128 9.83 0.000 .0032494 .0048677 lfam | -.1481981 .0082043 -18.06 0.000 -.1642783 -.1321179 child | .1030453 .0146897 7.01 0.000 .0742539 .1318366 _cons | .748789 .0208494 35.91 0.000 .7079249 .789653 ------------------------------------------------------------------------------ . . * Poisson PA estimator with unstructured error correlation and robust VCE . xtpoisson mdu lcoins ndisease female age lfam child, pa corr(unstr) vce(robust) Iteration 1: tolerance = .01585489 Iteration 2: tolerance = .00034066 Iteration 3: tolerance = 2.334e-06 Iteration 4: tolerance = 1.939e-08 GEE population-averaged model Number of obs = 20,186 Group and time vars: id year Number of groups = 5,908 Link: log Obs per group: Family: Poisson min = 1 Correlation: unstructured avg = 3.4 max = 5 Wald chi2(6) = 508.61 Scale parameter: 1 Prob > chi2 = 0.0000 (Std. Err. adjusted for clustering on id) ------------------------------------------------------------------------------ | Robust mdu | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- lcoins | -.0804454 .0077782 -10.34 0.000 -.0956904 -.0652004 ndisease | .0346067 .0024238 14.28 0.000 .0298561 .0393573 female | .1585075 .0334407 4.74 0.000 .0929649 .2240502 age | .0030901 .0015356 2.01 0.044 .0000803 .0060999 lfam | -.1406549 .0293672 -4.79 0.000 -.1982135 -.0830962 child | .1013677 .04301 2.36 0.018 .0170696 .1856658 _cons | .7764626 .0717221 10.83 0.000 .6358897 .9170354 ------------------------------------------------------------------------------ . . * Print out the correlation matrix . matrix list e(R) symmetric e(R)[5,5] c1 c2 c3 c4 c5 r1 1 r2 .53143297 1 r3 .40817495 .58547795 1 r4 .32357326 .35321716 .54321752 1 r5 .34152288 .29803555 .43767583 .61948751 1 . . * Allow for AR(1) correlation in y . xtpoisson mdu lcoins ndisease female age lfam child, pa corr(ar1) vce(robust) note: observations not equally spaced modal spacing is delta year = 1 unit 12 groups omitted from estimation note: some groups have fewer than 2 observations not possible to estimate correlations for those groups 265 groups omitted from estimation Iteration 1: tolerance = .01684555 Iteration 2: tolerance = .00011928 Iteration 3: tolerance = 3.741e-07 GEE population-averaged model Number of obs = 19,881 Group and time vars: id year Number of groups = 5,631 Link: log Obs per group: Family: Poisson min = 2 Correlation: AR(1) avg = 3.5 max = 5 Wald chi2(6) = 478.00 Scale parameter: 1 Prob > chi2 = 0.0000 (Std. Err. adjusted for clustering on id) ------------------------------------------------------------------------------ | Robust mdu | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- lcoins | -.0801371 .0079898 -10.03 0.000 -.0957968 -.0644773 ndisease | .0337386 .0025236 13.37 0.000 .0287924 .0386848 female | .1654749 .0344277 4.81 0.000 .0979978 .232952 age | .0040851 .0015731 2.60 0.009 .0010019 .0071683 lfam | -.1220327 .0303412 -4.02 0.000 -.1815003 -.0625651 child | .0797197 .0443214 1.80 0.072 -.0071486 .1665881 _cons | .7358995 .0742563 9.91 0.000 .5903599 .8814391 ------------------------------------------------------------------------------ . . *** 3. PANEL POISSON: RANDOM EFFECTS . . * Poisson random-effects estimator (gamma) with default standard errors . xtpoisson mdu lcoins ndisease female age lfam child, re Fitting Poisson model: Iteration 0: log likelihood = -62580.248 Iteration 1: log likelihood = -62579.401 Iteration 2: log likelihood = -62579.401 Fitting full model: Iteration 0: log likelihood = -43248.161 Iteration 1: log likelihood = -43240.57 Iteration 2: log likelihood = -43240.556 Iteration 3: log likelihood = -43240.556 Random-effects Poisson regression Number of obs = 20,186 Group variable: id Number of groups = 5,908 Random effects u_i ~ Gamma Obs per group: min = 1 avg = 3.4 max = 5 Wald chi2(6) = 637.49 Log likelihood = -43240.556 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ mdu | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- lcoins | -.0878258 .0068682 -12.79 0.000 -.1012873 -.0743642 ndisease | .0387629 .0022046 17.58 0.000 .034442 .0430839 female | .1667192 .0286298 5.82 0.000 .1106058 .2228325 age | .0019159 .0011134 1.72 0.085 -.0002663 .0040982 lfam | -.1351786 .0260022 -5.20 0.000 -.186142 -.0842152 child | .1082678 .0341477 3.17 0.002 .0413396 .1751961 _cons | .7574177 .0618346 12.25 0.000 .6362241 .8786112 -------------+---------------------------------------------------------------- /lnalpha | .0251256 .0209586 -.0159526 .0662038 -------------+---------------------------------------------------------------- alpha | 1.025444 .0214919 .984174 1.068444 ------------------------------------------------------------------------------ LR test of alpha=0: chibar2(01) = 3.9e+04 Prob >= chibar2 = 0.000 . . * Poisson random-effects estimator (gamma) with cluster-robust standard errors . xtpoisson mdu lcoins ndisease female age lfam child, re vce(cluster id) Fitting Poisson model: Iteration 0: log pseudolikelihood = -62580.248 Iteration 1: log pseudolikelihood = -62579.401 Iteration 2: log pseudolikelihood = -62579.401 Fitting full model: Iteration 0: log pseudolikelihood = -43248.161 Iteration 1: log pseudolikelihood = -43240.57 Iteration 2: log pseudolikelihood = -43240.556 Iteration 3: log pseudolikelihood = -43240.556 Random-effects Poisson regression Number of obs = 20,186 Group variable: id Number of groups = 5,908 Random effects u_i ~ Gamma Obs per group: min = 1 avg = 3.4 max = 5 Wald chi2(6) = 5407.91 Log pseudolikelihood = -43240.556 Prob > chi2 = 0.0000 (Std. Err. adjusted for 5,908 clusters in id) ------------------------------------------------------------------------------ | Robust mdu | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- lcoins | -.0878258 .0079239 -11.08 0.000 -.1033563 -.0722952 ndisease | .0387629 .0024087 16.09 0.000 .0340421 .0434838 female | .1667192 .0345869 4.82 0.000 .09893 .2345083 age | .0019159 .0016533 1.16 0.247 -.0013244 .0051563 lfam | -.1351786 .0360629 -3.75 0.000 -.2058606 -.0644966 child | .1082678 .0533869 2.03 0.043 .0036314 .2129043 _cons | .7574177 .0831229 9.11 0.000 .5944999 .9203355 -------------+---------------------------------------------------------------- /lnalpha | .0251256 .0905423 -.1523339 .2025852 -------------+---------------------------------------------------------------- alpha | 1.025444 .092846 .8587015 1.224564 ------------------------------------------------------------------------------ LR test of alpha=0: chibar2(01) = 3.9e+04 Prob >= chibar2 = 0.000 . * Preceding same as xtpoisson , re vce(robust) . . * Poisson random-effects estimator with normal intercept and default standard errors . xtpoisson mdu lcoins ndisease female age lfam child, re normal Fitting comparison Poisson model: Iteration 0: log likelihood = -62580.248 Iteration 1: log likelihood = -62579.401 Iteration 2: log likelihood = -62579.401 Fitting full model: tau = 0.0 log likelihood = -62579.401 tau = 0.1 log likelihood = -48555.969 tau = 0.2 log likelihood = -45691.914 tau = 0.3 log likelihood = -44608.086 tau = 0.4 log likelihood = -44155.322 tau = 0.5 log likelihood = -44187.327 Iteration 0: log likelihood = -43995.824 Iteration 1: log likelihood = -43258.374 Iteration 2: log likelihood = -43227.009 Iteration 3: log likelihood = -43226.889 Iteration 4: log likelihood = -43226.889 Random-effects Poisson regression Number of obs = 20,186 Group variable: id Number of groups = 5,908 Random effects u_i ~ Gaussian Obs per group: min = 1 avg = 3.4 max = 5 Integration method: mvaghermite Integration pts. = 12 Wald chi2(6) = 798.96 Log likelihood = -43226.889 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ mdu | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- lcoins | -.1145337 .0072788 -15.74 0.000 -.1287998 -.1002676 ndisease | .0408695 .0022941 17.81 0.000 .0363731 .045366 female | .208436 .0304848 6.84 0.000 .148687 .268185 age | .002674 .0011961 2.24 0.025 .0003297 .0050182 lfam | -.1443327 .0265365 -5.44 0.000 -.1963432 -.0923222 child | .0737146 .0344697 2.14 0.032 .0061553 .141274 _cons | .2872796 .0641625 4.48 0.000 .1615234 .4130359 -------------+---------------------------------------------------------------- /lnsig2u | .0549982 .0254991 .005021 .1049755 -------------+---------------------------------------------------------------- sigma_u | 1.027881 .013105 1.002514 1.05389 ------------------------------------------------------------------------------ LR test of sigma_u=0: chibar2(01) = 3.9e+04 Prob >= chibar2 = 0.000 . . * Poisson random-effects estimator with normal intercept and normal slope for one parameter . . *** 3. PANEL POISSON: MIXED MODELS . . * These take a very long time and are commented out . . /* > * Intercept only varies > meqrpoisson mdu lcoins ndisease female age lfam child || id: > * Previous is the same as > mepoisson mdu lcoins ndisease female age lfam child || id: > * And is the same as > xtpoisson mdu lcoins ndisease female age lfam child, re normal > > * Now also allow a slope parameter to vary > mepoisson mdu lcoins ndisease female age lfam child || id: ndisease > > * Now also allow slope parameter to covary with intercept parameter > mepoisson mdu lcoins ndisease female age lfam child || id: ndisease, /// > cov(unstructured) intpoints(9) > > */ . . *** 3. PANEL POISSON: FIXED EFFECTS . . * Poisson fixed-effects estimator with WRONG default standard errors . xtpoisson mdu lcoins ndisease female age lfam child, fe note: 265 groups (265 obs) dropped because of only one obs per group note: 666 groups (2130 obs) dropped because of all zero outcomes note: lcoins dropped because it is constant within group note: ndisease dropped because it is constant within group note: female dropped because it is constant within group Iteration 0: log likelihood = -24182.852 Iteration 1: log likelihood = -24173.211 Iteration 2: log likelihood = -24173.211 Conditional fixed-effects Poisson regression Number of obs = 17,791 Group variable: id Number of groups = 4,977 Obs per group: min = 2 avg = 3.6 max = 5 Wald chi2(3) = 19.24 Log likelihood = -24173.211 Prob > chi2 = 0.0002 ------------------------------------------------------------------------------ mdu | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- age | -.0112009 .0039024 -2.87 0.004 -.0188494 -.0035523 lfam | .0877134 .0554606 1.58 0.114 -.0209874 .1964141 child | .1059867 .0437744 2.42 0.015 .0201905 .1917829 ------------------------------------------------------------------------------ . . * Poisson fixed-effects estimator with panel-robust standard errors . xtpoisson mdu lcoins ndisease female age lfam child, fe vce(robust) note: 265 groups (265 obs) dropped because of only one obs per group note: 666 groups (2130 obs) dropped because of all zero outcomes note: lcoins dropped because it is constant within group note: ndisease dropped because it is constant within group note: female dropped because it is constant within group Iteration 0: log pseudolikelihood = -24182.852 Iteration 1: log pseudolikelihood = -24173.211 Iteration 2: log pseudolikelihood = -24173.211 Conditional fixed-effects Poisson regression Number of obs = 17,791 Group variable: id Number of groups = 4,977 Obs per group: min = 2 avg = 3.6 max = 5 Wald chi2(3) = 4.58 Log pseudolikelihood = -24173.211 Prob > chi2 = 0.2051 (Std. Err. adjusted for clustering on id) ------------------------------------------------------------------------------ | Robust mdu | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- age | -.0112009 .0091493 -1.22 0.221 -.0291331 .0067314 lfam | .0877134 .1160837 0.76 0.450 -.1398064 .3152332 child | .1059867 .0786326 1.35 0.178 -.0481304 .2601037 ------------------------------------------------------------------------------ . * This supplants earlier add-on xtpqml . * xtpqml mdu lcoins ndisease female age lfam child, fe i(id) cluster(id) . . *** 3. STATIC PANEL POISSON: ESTIMATOR COMPARISON . . * Comparison of Poisson panel estimators using panel-robust standard errors . global xlist lcoins ndisease female age lfam child . quietly poisson mdu $xlist, vce(cluster id) . estimates store POOLED . quietly xtpoisson mdu $xlist, pa corr(unstr) vce(robust) . estimates store POPAVE . quietly xtpoisson mdu $xlist, re vce(cluster id) . estimates store RE_GAMMA . quietly xtpoisson mdu $xlist, re normal vce(cluster id) . estimates store RE_NORMAL . quietly xtpoisson mdu $xlist, fe vce(robust) . estimates store FIXED . estimates table POOLED POPAVE RE_GAMMA RE_NORMAL FIXED, equations(1) /// > b(%8.4f) se stats(N ll) stfmt(%8.0f) --------------------------------------------------------------------- Variable | POOLED POPAVE RE_GAMMA RE_NOR~L FIXED -------------+------------------------------------------------------- #1 | lcoins | -0.0808 -0.0804 -0.0878 -0.1145 | 0.0080 0.0078 0.0079 0.0072 ndisease | 0.0339 0.0346 0.0388 0.0409 | 0.0026 0.0024 0.0024 0.0023 female | 0.1718 0.1585 0.1667 0.2084 | 0.0343 0.0334 0.0346 0.0310 age | 0.0041 0.0031 0.0019 0.0027 -0.0112 | 0.0017 0.0015 0.0017 0.0017 0.0091 lfam | -0.1482 -0.1407 -0.1352 -0.1443 0.0877 | 0.0323 0.0294 0.0361 0.0359 0.1161 child | 0.1030 0.1014 0.1083 0.0737 0.1060 | 0.0507 0.0430 0.0534 0.0534 0.0786 _cons | 0.7488 0.7765 0.7574 0.2873 | 0.0786 0.0717 0.0831 0.0829 -------------+------------------------------------------------------- /lnalpha | 0.0251 | 0.0905 /lnsig2u | 0.0550 | 0.0271 -------------+------------------------------------------------------- Statistics | N | 20186 20186 20186 20186 17791 ll | -62579 -43241 -43227 -24173 --------------------------------------------------------------------- legend: b/se . . /* In early versions of Stata xtpoisson re does not do panel-robust se's and instead > bootstrap as follows > xtpoisson mdu lcoins ndisease female age lfam child, re vce(boot, reps(100) seed(10101)) > */ . . *** 3. DYNAMIC PANEL POISSON: ESTIMATOR COMPARISON . . * Variable descriptions and summary statistics . use racd09data.dta, clear . global XLISTD PAT1 LOGR LOGR1 LOGR2 LOGK SCISECT dyear2 dyear3 dyear4 dyear5 . describe PAT $XLISTD storage display value variable name type format label variable label ------------------------------------------------------------------------------------------------ PAT float %9.0g Number of (successful) patents applied for this year PAT1 float %9.0g Number of (successful) patents applied for lagged one year LOGR float %9.0g Logarithm of R&D spending this year (in 1972$) LOGR1 float %9.0g Logarithm of R&D spending lagged one year (in 1972$) LOGR2 float %9.0g Logarithm of R&D spending lagged two years (in 1972$) LOGK float %9.0g Logarithm of the book value of capital in 1972 SCISECT float %9.0g Equals 1 if firm in the scientific sector dyear2 float %9.0g = 1 if YEAR = 2 dyear3 float %9.0g = 1 if YEAR = 3 dyear4 float %9.0g = 1 if YEAR = 4 dyear5 float %9.0g = 1 if YEAR = 5 . summarize PAT1 Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- PAT1 | 1,730 35.87341 72.76243 0 528 . . * Summarize all . summarize $XLISTD Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- PAT1 | 1,730 35.87341 72.76243 0 528 LOGR | 1,730 1.256163 2.006314 -3.84868 7.03432 LOGR1 | 1,730 1.233574 1.984091 -3.84868 7.06524 LOGR2 | 1,730 1.218499 1.966808 -3.84868 7.06524 LOGK | 1,730 3.921063 2.093117 -1.76965 9.66626 -------------+--------------------------------------------------------- SCISECT | 1,730 .4248555 .494464 0 1 dyear2 | 1,730 .2 .4001157 0 1 dyear3 | 1,730 .2 .4001157 0 1 dyear4 | 1,730 .2 .4001157 0 1 dyear5 | 1,730 .2 .4001157 0 1 . . *** 3. DYNAMIC MODELS USING EXPONENTIAL FEEDBACK MODEL . . *** 3. NON-FIXED EFFECTS DYNAMIC MODELS . . * Pooled Poisson . poisson PAT $XLISTD, vce(cluster id) nolog Poisson regression Number of obs = 1,730 Wald chi2(10) = 671.99 Prob > chi2 = 0.0000 Log pseudolikelihood = -14717.183 Pseudo R2 = 0.8045 (Std. Err. adjusted for 346 clusters in id) ------------------------------------------------------------------------------ | Robust PAT | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- PAT1 | .0033814 .0006154 5.49 0.000 .0021753 .0045875 LOGR | .3590677 .1435441 2.50 0.012 .0777264 .640409 LOGR1 | -.1592754 .1004438 -1.59 0.113 -.3561416 .0375908 LOGR2 | .133313 .138718 0.96 0.337 -.1385693 .4051953 LOGK | .1831944 .0459439 3.99 0.000 .093146 .2732428 SCISECT | .288793 .1354546 2.13 0.033 .0233069 .5542792 dyear2 | -.0424498 .0380379 -1.12 0.264 -.1170026 .0321031 dyear3 | -.007469 .0367145 -0.20 0.839 -.079428 .06449 dyear4 | -.1213673 .0466182 -2.60 0.009 -.2127373 -.0299973 dyear5 | -.1104694 .0429585 -2.57 0.010 -.1946665 -.0262724 _cons | 1.329976 .2099348 6.34 0.000 .9185113 1.74144 ------------------------------------------------------------------------------ . estimates store DPCS . display "Table 9.5: first column Sum ln R" Table 9.5: first column Sum ln R . lincom LOGR + LOGR1 + LOGR2 ( 1) [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 = 0 ------------------------------------------------------------------------------ PAT | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .3331053 .0617574 5.39 0.000 .2120631 .4541475 ------------------------------------------------------------------------------ . . * Population Averaged Poisson with exchangeable errors . * Following standard errors are preferred . xtpoisson PAT $XLISTD, pa vce(robust) Iteration 1: tolerance = .07257923 Iteration 2: tolerance = .01848274 Iteration 3: tolerance = .00150935 Iteration 4: tolerance = .00009856 Iteration 5: tolerance = 4.114e-06 Iteration 6: tolerance = 2.943e-07 GEE population-averaged model Number of obs = 1,730 Group variable: id Number of groups = 346 Link: log Obs per group: Family: Poisson min = 5 Correlation: exchangeable avg = 5.0 max = 5 Wald chi2(10) = 507.36 Scale parameter: 1 Prob > chi2 = 0.0000 (Std. Err. adjusted for clustering on id) ------------------------------------------------------------------------------ | Robust PAT | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- PAT1 | .0018599 .0003348 5.55 0.000 .0012036 .0025161 LOGR | .3788088 .0661193 5.73 0.000 .2492173 .5084003 LOGR1 | -.0801661 .0742112 -1.08 0.280 -.2256175 .0652852 LOGR2 | .0778156 .0586969 1.33 0.185 -.0372282 .1928595 LOGK | .2228567 .0448267 4.97 0.000 .1349979 .3107154 SCISECT | .3706687 .155546 2.38 0.017 .0658041 .6755333 dyear2 | -.0439155 .0237863 -1.85 0.065 -.0905358 .0027047 dyear3 | -.0323041 .0256807 -1.26 0.208 -.0826372 .0180291 dyear4 | -.1543135 .0384815 -4.01 0.000 -.2297359 -.078891 dyear5 | -.1694393 .0349305 -4.85 0.000 -.2379018 -.1009767 _cons | 1.117729 .2222871 5.03 0.000 .6820544 1.553404 ------------------------------------------------------------------------------ . display "Table 9.5: second column Sum ln R" Table 9.5: second column Sum ln R . lincom LOGR + LOGR1 + LOGR2 ( 1) LOGR + LOGR1 + LOGR2 = 0 ------------------------------------------------------------------------------ PAT | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .3764583 .0531352 7.08 0.000 .2723151 .4806015 ------------------------------------------------------------------------------ . . * Poisson Random Effects - gamma . estimates store DPPA . xtpoisson PAT $XLISTD, re vce(robust) Fitting Poisson model: Iteration 0: log pseudolikelihood = -280117.7 Iteration 1: log pseudolikelihood = -137135.22 Iteration 2: log pseudolikelihood = -52736.981 Iteration 3: log pseudolikelihood = -18503.228 Iteration 4: log pseudolikelihood = -14743.431 Iteration 5: log pseudolikelihood = -14717.192 Iteration 6: log pseudolikelihood = -14717.183 Iteration 7: log pseudolikelihood = -14717.183 Fitting full model: Iteration 0: log pseudolikelihood = -5362.4562 Iteration 1: log pseudolikelihood = -5244.6087 Iteration 2: log pseudolikelihood = -5189.458 Iteration 3: log pseudolikelihood = -5188.0237 Iteration 4: log pseudolikelihood = -5188.0204 Iteration 5: log pseudolikelihood = -5188.0204 Random-effects Poisson regression Number of obs = 1,730 Group variable: id Number of groups = 346 Random effects u_i ~ Gamma Obs per group: min = 5 avg = 5.0 max = 5 Wald chi2(10) = 5845.34 Log pseudolikelihood = -5188.0204 Prob > chi2 = 0.0000 (Std. Err. adjusted for clustering on id) ------------------------------------------------------------------------------ | Robust PAT | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- PAT1 | .0012825 .0004804 2.67 0.008 .0003411 .002224 LOGR | .44618 .0739859 6.03 0.000 .3011702 .5911898 LOGR1 | -.0595111 .083875 -0.71 0.478 -.223903 .1048808 LOGR2 | .1032655 .0670018 1.54 0.123 -.0280556 .2345866 LOGK | .3001179 .0620428 4.84 0.000 .1785162 .4217196 SCISECT | .2804724 .120413 2.33 0.020 .0444673 .5164775 dyear2 | -.0463529 .0217709 -2.13 0.033 -.0890231 -.0036827 dyear3 | -.0416408 .0254236 -1.64 0.101 -.0914701 .0081885 dyear4 | -.1680358 .0378902 -4.43 0.000 -.2422993 -.0937723 dyear5 | -.1963685 .0343281 -5.72 0.000 -.2636503 -.1290867 _cons | .3724811 .1889177 1.97 0.049 .0022092 .7427529 -------------+---------------------------------------------------------------- /lnalpha | -.180793 .4387085 -1.040646 .6790599 -------------+---------------------------------------------------------------- alpha | .8346081 .3661497 .3532265 1.972023 ------------------------------------------------------------------------------ LR test of alpha=0: chibar2(01) = 1.9e+04 Prob >= chibar2 = 0.000 . estimates store DPRE . display "Table 9.5: third column Sum ln R" Table 9.5: third column Sum ln R . lincom LOGR + LOGR1 + LOGR2 ( 1) [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 = 0 ------------------------------------------------------------------------------ PAT | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .4899344 .0758524 6.46 0.000 .3412665 .6386023 ------------------------------------------------------------------------------ . . generate PAT_YEAR0 = PAT1 if YEAR==1 // = PAT1 in YEAR 1 and missing in YEARS 1-5 (1,384 missing values generated) . bysort id: egen PAT_INITIAL = mean(PAT_YEAR0) // Replaces missings with PAT1 in YEAR1 . . * Conditionally Correlated Random Effects . sort id . by id: egen LOGRMEAN = mean(LOGR) . by id: egen LOGR1MEAN = mean(LOGR1) . by id: egen LOGR2MEAN = mean(LOGR2) . by id: egen LOGR3MEAN = mean(LOGR3) . by id: egen LOGR4MEAN = mean(LOGR4) . by id: egen LOGR5MEAN = mean(LOGR5) . global MEANS LOGRMEAN LOGR1MEAN LOGR2MEAN LOGR3MEAN LOGR4MEAN LOGR5MEAN . . global XLISTD2 PAT1 LOGR LOGR1 LOGR2 LOGK SCISECT PAT_INITIAL LOGRMEAN LOGR1MEAN /// > LOGR2MEAN dyear2 dyear3 dyear4 dyear5 . . * Correlated random effects versions of the same . * Cross-section Poisson . poisson PAT $XLISTD2, vce(cluster id) Iteration 0: log pseudolikelihood = -279821.89 Iteration 1: log pseudolikelihood = -169670.44 (backed up) Iteration 2: log pseudolikelihood = -94501.083 Iteration 3: log pseudolikelihood = -18376.372 Iteration 4: log pseudolikelihood = -14744.374 Iteration 5: log pseudolikelihood = -14580.185 Iteration 6: log pseudolikelihood = -14579.679 Iteration 7: log pseudolikelihood = -14579.679 Poisson regression Number of obs = 1,730 Wald chi2(14) = 764.86 Prob > chi2 = 0.0000 Log pseudolikelihood = -14579.679 Pseudo R2 = 0.8063 (Std. Err. adjusted for 346 clusters in id) ------------------------------------------------------------------------------ | Robust PAT | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- PAT1 | .004659 .0013789 3.38 0.001 .0019563 .0073616 LOGR | .3680191 .1265515 2.91 0.004 .1199827 .6160554 LOGR1 | -.1761849 .1331148 -1.32 0.186 -.4370851 .0847152 LOGR2 | -.0392388 .0780056 -0.50 0.615 -.192127 .1136494 LOGK | .1720819 .0453834 3.79 0.000 .0831321 .2610317 SCISECT | .2719629 .1217646 2.23 0.026 .0333086 .5106172 PAT_INITIAL | -.0014259 .0011071 -1.29 0.198 -.0035959 .000744 LOGRMEAN | .5861149 1.094472 0.54 0.592 -1.559011 2.731241 LOGR1MEAN | -1.556635 1.834338 -0.85 0.396 -5.151871 2.038601 LOGR2MEAN | 1.178711 .8811638 1.34 0.181 -.5483385 2.90576 dyear2 | -.0402669 .0413444 -0.97 0.330 -.1213004 .0407666 dyear3 | -.0022761 .038042 -0.06 0.952 -.0768371 .0722849 dyear4 | -.1118548 .0457641 -2.44 0.015 -.2015509 -.0221588 dyear5 | -.0772369 .0404438 -1.91 0.056 -.1565052 .0020315 _cons | 1.334279 .2061876 6.47 0.000 .9301587 1.738399 ------------------------------------------------------------------------------ . estimates store DPCS2 . * Population averaged Poisson with exchangeable errrors . xtpoisson PAT $XLISTD2, pa vce(robust) Iteration 1: tolerance = .63412383 Iteration 2: tolerance = .13295781 Iteration 3: tolerance = .00696397 Iteration 4: tolerance = .00007082 Iteration 5: tolerance = .00006766 Iteration 6: tolerance = 5.306e-06 Iteration 7: tolerance = 7.561e-07 GEE population-averaged model Number of obs = 1,730 Group variable: id Number of groups = 346 Link: log Obs per group: Family: Poisson min = 5 Correlation: exchangeable avg = 5.0 max = 5 Wald chi2(14) = 544.01 Scale parameter: 1 Prob > chi2 = 0.0000 (Std. Err. adjusted for clustering on id) ------------------------------------------------------------------------------ | Robust PAT | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- PAT1 | .0013081 .0003492 3.75 0.000 .0006237 .0019925 LOGR | .3124704 .0680773 4.59 0.000 .1790413 .4458995 LOGR1 | -.1008425 .0717563 -1.41 0.160 -.2414823 .0397973 LOGR2 | .0454956 .0597698 0.76 0.447 -.071651 .1626421 LOGK | .1770891 .0540251 3.28 0.001 .0712018 .2829764 SCISECT | .3222529 .1679943 1.92 0.055 -.0070098 .6515157 PAT_INITIAL | .0016659 .0006676 2.50 0.013 .0003575 .0029743 LOGRMEAN | -.2157091 1.082218 -0.20 0.842 -2.336817 1.905399 LOGR1MEAN | .2100467 1.899797 0.11 0.912 -3.513487 3.93358 LOGR2MEAN | .0995838 .9866408 0.10 0.920 -1.834197 2.033364 dyear2 | -.0417337 .020654 -2.02 0.043 -.0822148 -.0012526 dyear3 | -.0308182 .0244092 -1.26 0.207 -.0786593 .0170229 dyear4 | -.1443294 .0349789 -4.13 0.000 -.2128867 -.0757721 dyear5 | -.15899 .0333839 -4.76 0.000 -.2244212 -.0935588 _cons | 1.360092 .2377173 5.72 0.000 .8941745 1.826009 ------------------------------------------------------------------------------ . estimates store DPPA2 . . * Poisson Random Effects - gamma . xtpoisson PAT $XLISTD2, re vce(robust) Fitting Poisson model: Iteration 0: log pseudolikelihood = -279821.89 Iteration 1: log pseudolikelihood = -169670.44 (backed up) Iteration 2: log pseudolikelihood = -94501.083 Iteration 3: log pseudolikelihood = -18376.372 Iteration 4: log pseudolikelihood = -14744.374 Iteration 5: log pseudolikelihood = -14580.185 Iteration 6: log pseudolikelihood = -14579.679 Iteration 7: log pseudolikelihood = -14579.679 Fitting full model: Iteration 0: log pseudolikelihood = -5537.2779 Iteration 1: log pseudolikelihood = -5367.0286 Iteration 2: log pseudolikelihood = -5160.9636 Iteration 3: log pseudolikelihood = -5156.4736 Iteration 4: log pseudolikelihood = -5156.4535 Iteration 5: log pseudolikelihood = -5156.4535 Random-effects Poisson regression Number of obs = 1,730 Group variable: id Number of groups = 346 Random effects u_i ~ Gamma Obs per group: min = 5 avg = 5.0 max = 5 Wald chi2(14) = 5218.64 Log pseudolikelihood = -5156.4535 Prob > chi2 = 0.0000 (Std. Err. adjusted for clustering on id) ------------------------------------------------------------------------------ | Robust PAT | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- PAT1 | .0012248 .00048 2.55 0.011 .0002841 .0021656 LOGR | .3404846 .0801862 4.25 0.000 .1833225 .4976467 LOGR1 | -.1040997 .0842269 -1.24 0.216 -.2691813 .0609819 LOGR2 | .0474496 .068346 0.69 0.488 -.0865061 .1814053 LOGK | .0447689 .0529914 0.84 0.398 -.0590924 .1486302 SCISECT | -.0397818 .1094844 -0.36 0.716 -.2543672 .1748037 PAT_INITIAL | .0044761 .0016363 2.74 0.006 .001269 .0076833 LOGRMEAN | -.1025678 .8365405 -0.12 0.902 -1.742157 1.537022 LOGR1MEAN | -.2128072 1.619569 -0.13 0.895 -3.387104 2.96149 LOGR2MEAN | .7320889 .8992488 0.81 0.416 -1.030406 2.494584 dyear2 | -.0447412 .0210503 -2.13 0.034 -.0859991 -.0034833 dyear3 | -.0372623 .0251227 -1.48 0.138 -.0865018 .0119773 dyear4 | -.1535682 .0364036 -4.22 0.000 -.2249178 -.0822185 dyear5 | -.1702754 .0346658 -4.91 0.000 -.2382191 -.1023318 _cons | 1.03913 .1692442 6.14 0.000 .7074175 1.370842 -------------+---------------------------------------------------------------- /lnalpha | -.3130783 .4391927 -1.17388 .5477236 -------------+---------------------------------------------------------------- alpha | .7311927 .3211345 .309165 1.729312 ------------------------------------------------------------------------------ LR test of alpha=0: chibar2(01) = 1.9e+04 Prob >= chibar2 = 0.000 . estimates store DPCCRE . display "Table 9.6: first column Sum ln R" Table 9.6: first column Sum ln R . lincom LOGR + LOGR1 + LOGR2 ( 1) [PAT]LOGR + [PAT]LOGR1 + [PAT]LOGR2 = 0 ------------------------------------------------------------------------------ PAT | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .2838345 .0966094 2.94 0.003 .0944836 .4731855 ------------------------------------------------------------------------------ . . estimates table DPCS DPCS2 DPPA DPPA2 DPRE DPCCRE, b(%7.4f) se(%7.3f) /// > stats(N ll) stfmt(%9.1f) modelwidth(9) equations(1) -------------------------------------------------------------------------------------- Variable | DPCS DPCS2 DPPA DPPA2 DPRE DPCCRE -------------+------------------------------------------------------------------------ #1 | PAT1 | 0.0034 0.0047 0.0019 0.0013 0.0013 0.0012 | 0.001 0.001 0.000 0.000 0.000 0.000 LOGR | 0.3591 0.3680 0.3788 0.3125 0.4462 0.3405 | 0.144 0.127 0.066 0.068 0.074 0.080 LOGR1 | -0.1593 -0.1762 -0.0802 -0.1008 -0.0595 -0.1041 | 0.100 0.133 0.074 0.072 0.084 0.084 LOGR2 | 0.1333 -0.0392 0.0778 0.0455 0.1033 0.0474 | 0.139 0.078 0.059 0.060 0.067 0.068 LOGK | 0.1832 0.1721 0.2229 0.1771 0.3001 0.0448 | 0.046 0.045 0.045 0.054 0.062 0.053 SCISECT | 0.2888 0.2720 0.3707 0.3223 0.2805 -0.0398 | 0.135 0.122 0.156 0.168 0.120 0.109 dyear2 | -0.0424 -0.0403 -0.0439 -0.0417 -0.0464 -0.0447 | 0.038 0.041 0.024 0.021 0.022 0.021 dyear3 | -0.0075 -0.0023 -0.0323 -0.0308 -0.0416 -0.0373 | 0.037 0.038 0.026 0.024 0.025 0.025 dyear4 | -0.1214 -0.1119 -0.1543 -0.1443 -0.1680 -0.1536 | 0.047 0.046 0.038 0.035 0.038 0.036 dyear5 | -0.1105 -0.0772 -0.1694 -0.1590 -0.1964 -0.1703 | 0.043 0.040 0.035 0.033 0.034 0.035 PAT_INITIAL | -0.0014 0.0017 0.0045 | 0.001 0.001 0.002 LOGRMEAN | 0.5861 -0.2157 -0.1026 | 1.094 1.082 0.837 LOGR1MEAN | -1.5566 0.2100 -0.2128 | 1.834 1.900 1.620 LOGR2MEAN | 1.1787 0.0996 0.7321 | 0.881 0.987 0.899 _cons | 1.3300 1.3343 1.1177 1.3601 0.3725 1.0391 | 0.210 0.206 0.222 0.238 0.189 0.169 -------------+------------------------------------------------------------------------ /lnalpha | -0.1808 -0.3131 | 0.439 0.439 -------------+------------------------------------------------------------------------ Statistics | N | 1730 1730 1730 1730 1730 1730 ll | -14717.2 -14579.7 -5188.0 -5156.5 -------------------------------------------------------------------------------------- legend: b/se . . *** 3. FIXED EFFECTS DYNAMIC MODELS . . * Fixed effects GMM using Chamberlain transformation . * This program is the same as gmm_poipre in Stata manual [r]gmm . program gmm_poipre 1. version 11 2. syntax varlist if, at(name) myrhs(varlist) /// > mylhs(varlist) myidvar(varlist) 3. quietly { 4. tempvar mu mubar ybar 5. gen double `mu' = 0 `if' 6. local j = 1 7. foreach var of varlist `myrhs' { 8. replace `mu' = `mu' + `var'*`at'[1,`j'] `if' 9. local j = `j' + 1 10. } 11. replace `mu' = exp(`mu') 12. replace `varlist' = L.`mylhs' - L.`mu'*`mylhs'/`mu' `if' 13. } 14. end . . * Only include time-varying regressors . * Also here year 1 is dropped, so drop the year 2 dummy . * Regressors . global XLISTTV PAT1 LOGR LOGR1 LOGR2 dyear3 dyear4 dyear5 . * Instruments in just-identified case . global IVLISTTV PAT2 LOGR1 LOGR2 LOGR3 dyear3 dyear4 dyear5 . * Instruments in over-identified case . global IVLISTTV2 PAT2 PAT3 PAT4 LOGR1 LOGR2 LOGR3 dyear3 dyear4 dyear5 . . * Just-identified . gmm gmm_poipre, mylhs(PAT) myrhs($XLISTTV) myidvar(id) nequations(1) /// > parameters($XLISTTV) instruments($IVLISTTV, noconstant) onestep vce(cluster id) note: 346 missing values returned for equation 1 at initial values Step 1 Iteration 0: GMM criterion Q(b) = 13.821058 Iteration 1: GMM criterion Q(b) = .96221647 Iteration 2: GMM criterion Q(b) = .00240722 Iteration 3: GMM criterion Q(b) = 2.011e-08 Iteration 4: GMM criterion Q(b) = 9.320e-20 note: model is exactly identified GMM estimation Number of parameters = 7 Number of moments = 7 Initial weight matrix: Unadjusted Number of obs = 1,384 (Std. Err. adjusted for 346 clusters in id) ------------------------------------------------------------------------------ | Robust | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- /PAT1 | .0021701 .0011062 1.96 0.050 2.12e-06 .0043381 /LOGR | -.62016 1.356658 -0.46 0.648 -3.279161 2.038841 /LOGR1 | -.100405 .127623 -0.79 0.431 -.3505415 .1497316 /LOGR2 | .0315067 .0896787 0.35 0.725 -.1442603 .2072738 /dyear3 | .0576212 .0862853 0.67 0.504 -.1114948 .2267372 /dyear4 | .0028215 .1792061 0.02 0.987 -.348416 .354059 /dyear5 | .0723403 .3120826 0.23 0.817 -.5393303 .6840108 ------------------------------------------------------------------------------ Instruments for equation 1: PAT2 LOGR1 LOGR2 LOGR3 dyear3 dyear4 dyear5 . estimates store DPGMM . . * Overidentified . gmm gmm_poipre, mylhs(PAT) myrhs($XLISTTV) myidvar(id) nequations(1) /// > parameters($XLISTTV) instruments($IVLISTTV2, noconstant) twostep vce(cluster id) note: 346 missing values returned for equation 1 at initial values Step 1 Iteration 0: GMM criterion Q(b) = 20.419245 Iteration 1: GMM criterion Q(b) = 9.9407626 Iteration 2: GMM criterion Q(b) = 5.1112115 Iteration 3: GMM criterion Q(b) = 4.8687296 Iteration 4: GMM criterion Q(b) = 4.8094014 Iteration 5: GMM criterion Q(b) = 4.8055828 Iteration 6: GMM criterion Q(b) = 4.8045584 Iteration 7: GMM criterion Q(b) = 4.8043407 Iteration 8: GMM criterion Q(b) = 4.8042854 Iteration 9: GMM criterion Q(b) = 4.8042721 Iteration 10: GMM criterion Q(b) = 4.8042688 Iteration 11: GMM criterion Q(b) = 4.804268 Iteration 12: GMM criterion Q(b) = 4.8042678 Step 2 Iteration 0: GMM criterion Q(b) = .00394725 Iteration 1: GMM criterion Q(b) = .00191424 Iteration 2: GMM criterion Q(b) = .00185483 Iteration 3: GMM criterion Q(b) = .00185468 Iteration 4: GMM criterion Q(b) = .00185468 GMM estimation Number of parameters = 7 Number of moments = 9 Initial weight matrix: Unadjusted Number of obs = 1,384 GMM weight matrix: Cluster (id) (Std. Err. adjusted for 346 clusters in id) ------------------------------------------------------------------------------ | Robust | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- /PAT1 | .0022005 .0013377 1.64 0.100 -.0004214 .0048224 /LOGR | -.9212601 1.289654 -0.71 0.475 -3.448935 1.606415 /LOGR1 | -.0807447 .1821353 -0.44 0.658 -.4377233 .2762339 /LOGR2 | .0503219 .0980242 0.51 0.608 -.141802 .2424458 /dyear3 | .0671206 .092732 0.72 0.469 -.1146307 .2488719 /dyear4 | .043572 .1840938 0.24 0.813 -.3172453 .4043893 /dyear5 | .1373269 .3403286 0.40 0.687 -.529705 .8043588 ------------------------------------------------------------------------------ Instruments for equation 1: PAT2 PAT3 PAT4 LOGR1 LOGR2 LOGR3 dyear3 dyear4 dyear5 . estimates store DPGMMOID . display "Table 9.6: second column Sum ln R" Table 9.6: second column Sum ln R . lincom _b[LOGR:_cons]+_b[LOGR1:_cons]+_b[LOGR2:_cons] ( 1) [LOGR]_cons + [LOGR1]_cons + [LOGR2]_cons = 0 ------------------------------------------------------------------------------ | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | -.9516828 1.449425 -0.66 0.511 -3.792505 1.889139 ------------------------------------------------------------------------------ . estat overid Test of overidentifying restriction: Hansen's J chi2(2) = 2.56688 (p = 0.2771) . * predict residGMM . * correlate residGMM L.residGMM L2.residGMM . . *** CHECK: THIS DOES POISSON FE USING GMM COMMAND . . * This program is the same as gmm_poi in Stata manual [r]gmm . program gmm_poi2 1. version 11 2. syntax varlist if, at(name) myrhs(varlist) /// > mylhs(varlist) myidvar(varlist) 3. quietly { 4. tempvar mu mubar ybar 5. gen double `mu' = 0 `if' 6. local j = 1 7. foreach var of varlist `myrhs' { 8. replace `mu' = `mu' + `var'*`at'[1,`j'] `if' 9. local j = `j' + 1 10. } 11. replace `mu' = exp(`mu') 12. egen double `mubar' = mean(`mu') `if', by(`myidvar') 13. egen double `ybar' = mean(`mylhs') `if', by(`myidvar') 14. replace `varlist' = `mylhs' - `mu'*`ybar'/`mubar' `if' 15. } 16. end . global XLISTTIMEVARYING LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5 . gmm gmm_poi2, mylhs(PAT) myrhs($XLISTTIMEVARYING) /// > myidvar(id) nequations(1) parameters($XLISTTIMEVARYING) /// > instruments($XLISTTIMEVARYING, noconstant) onestep vce(cluster id) Step 1 Iteration 0: GMM criterion Q(b) = 2.9813256 Iteration 1: GMM criterion Q(b) = .00139024 Iteration 2: GMM criterion Q(b) = 5.343e-10 Iteration 3: GMM criterion Q(b) = 1.852e-22 note: model is exactly identified GMM estimation Number of parameters = 10 Number of moments = 10 Initial weight matrix: Unadjusted Number of obs = 1,730 (Std. Err. adjusted for 346 clusters in id) ------------------------------------------------------------------------------ | Robust | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- /LOGR | .3222105 .0807547 3.99 0.000 .1639341 .4804868 /LOGR1 | -.0871295 .0712049 -1.22 0.221 -.2266885 .0524295 /LOGR2 | .0785816 .0620597 1.27 0.205 -.0430532 .2002164 /LOGR3 | .00106 .078183 0.01 0.989 -.1521758 .1542958 /LOGR4 | -.0046414 .063583 -0.07 0.942 -.1292617 .119979 /LOGR5 | .0026068 .0759235 0.03 0.973 -.1462004 .1514141 /dyear2 | -.0426076 .0167407 -2.55 0.011 -.0754187 -.0097965 /dyear3 | -.0400462 .0248168 -1.61 0.107 -.0886862 .0085939 /dyear4 | -.1571185 .035894 -4.38 0.000 -.2274694 -.0867676 /dyear5 | -.1980306 .0368759 -5.37 0.000 -.2703059 -.1257552 ------------------------------------------------------------------------------ Instruments for equation 1: LOGR LOGR1 LOGR2 LOGR3 LOGR4 LOGR5 dyear2 dyear3 dyear4 dyear5 . estimates store PFEGMM . . . ********** CLOSE OUTPUT . . * log close . * clear . * exit . . end of do-file . exit, clear