--------------------------------------------------------------------------------- name: log: c:\Users\ccameron\Dropbox\Desktop\TEACHING\190\Methods\panel.txt log type: text opened on: 21 Mar 2023, 14:08:18 . . ********** OVERVIEW OF panel.do ********** . . * This STATA program is an example of regression discontinuity design . . * Program by A. Colin Cameron Dept. of Economics Univ. of California - Davis . * Used for ECN 190 Research with Economics Data . . * To run you need file . * AED_NBA.DTA . * in your directory . . * The dataset is used in chapter 17.3 of . * A. Colin Cameron Analysis of Economics Data: An Introduction to Econometics . * https://cameron.econ.ucdavis.edu/ . . * Original source is Edwin Bang (2012), . * "Collective Bargaining Agreements, Star Players, and Inequality in the NBA" . * Undergraduate Honors thesis, Dept. of Economics, U.C. Davis. . . ********** SETUP ********** . . clear all . set scheme s1mono /* Graphics scheme */ . . **** 17 FIXED EFFECTS PANEL DATA EXAMPLE: NBA TEAM REVENUE . . clear . use AED_NBA.DTA (Data for A. Colin Cameron (2022), ANALYSIS OF ECONOMIC DATA, Amazon) . describe Contains data from AED_NBA.DTA Observations: 286 Data for A. Colin Cameron (2022), ANALYSIS OF ECONOMIC DATA, Amazon Variables: 65 22 Jan 2022 15:04 --------------------------------------------------------------------------------- Variable Storage Display Value name type format label Variable label --------------------------------------------------------------------------------- teamandyear str21 %21s Team and Season team str13 %13s Team name teamid byte %8.0g 1 to 29 season byte %8.0g 1 to 10 seasonsq float %9.0g Season squared revenue float %8.0g Team revenue in millions of 1999 $ lnrevenue float %9.0g Natural logarithm of team revenue value float %8.0g Team value in millions $ lnvalue float %9.0g Natural logarithm of team value$ wins byte %8.0g Wins in previous season including playoff games playoff byte %8.0g = 1 if made playoffs in previous season, 0 otherwise champ byte %8.0g = 1 if won championship in previous season, 0 otherwise allstars byte %8.0g Number of players on team voted as all-stars that season relocated byte %8.0g = 1 in all years after if team has relocated after 2000 othfranchise byte %8.0g Number of other major pro sports franchises in city newarenayr1 byte %8.0g = 1 if in first year of a new arena, 0 otherwise newarenayr2 byte %8.0g = 1 if in second year of a new arena, 0 otherwise newarenayr3 byte %8.0g = 1 if in third year of a new arena, 0 otherwise newarenayr4 byte %8.0g = 1 if in fourth year of a new arena, 0 otherwise cpi float %9.0g CPI all urban consumers all items realgdp long %12.0g Real GDP of city in millions $ realgdppc long %12.0g Real GDP of city per capita citypop float %9.0g City population in millions lncitypop float %8.0g Natural logarithm of city population gdpmetro long %12.0g Metropolitan nominal GDP that year in millions $ lngdpmetro float %9.0g Natural log of metropolitan nominal GDP that year season1 byte %8.0g season2 byte %8.0g season3 byte %8.0g season4 byte %8.0g season5 byte %8.0g season6 byte %8.0g season7 byte %8.0g season8 byte %8.0g season9 byte %8.0g season10 byte %8.0g bucksdummy byte %8.0g grizzliesdummy byte %8.0g hawksdummy byte %8.0g timberwolvesd~y byte %8.0g bobcatsdummy byte %8.0g pacersdummy byte %8.0g hornetsdummy byte %8.0g kingsdummy byte %8.0g sixersdummy byte %8.0g nuggetsdummy byte %8.0g clippersdummy byte %8.0g wizardsdummy byte %8.0g cavaliersdummy byte %8.0g pistonsdummy byte %8.0g jazzdummy byte %8.0g sonicsdummy byte %8.0g netsdummy byte %8.0g trailblazersd~y byte %8.0g magicdummy byte %8.0g sunsdummy byte %8.0g spursdummy byte %8.0g warriorsdummy byte %8.0g rocketsdummy byte %8.0g heatdummy byte %8.0g celticsdummy byte %8.0g mavericksdummy byte %8.0g bullsdummy byte %8.0g lakersdummy byte %8.0g knicksdummy byte %8.0g --------------------------------------------------------------------------------- Sorted by: . summarize Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- teamandyear | 0 team | 0 teamid | 286 14.86014 8.354935 1 29 season | 286 5.541958 2.872126 1 10 seasonsq | 286 38.93357 32.48631 1 100 -------------+--------------------------------------------------------- revenue | 286 95.71404 24.44207 58.49582 187.7212 lnrevenue | 286 4.532293 .2359855 4.068955 5.234958 value | 286 284.1903 80.28601 158.9404 692.4142 lnvalue | 286 5.614849 .2575733 5.068529 6.540184 wins | 286 41.03497 12.43758 9 67 -------------+--------------------------------------------------------- playoff | 286 .5454545 .4988024 0 1 champ | 286 .034965 .1840132 0 1 allstars | 286 .8601399 .8713885 0 4 relocated | 286 .0769231 .2669364 0 1 othfranchise | 286 2.800699 2.316713 0 8 -------------+--------------------------------------------------------- newarenayr1 | 286 .020979 .1435652 0 1 newarenayr2 | 286 .0174825 .1312903 0 1 newarenayr3 | 286 .0384615 .1926448 0 1 newarenayr4 | 286 .048951 .2161439 0 1 cpi | 286 118.4309 8.078975 105.7 129.98 -------------+--------------------------------------------------------- realgdp | 286 274674.3 272015.6 46808 1147917 realgdppc | 286 51339.47 8036.258 26681 72181 citypop | 286 5.149763 4.754586 .9848863 18.92005 lncitypop | 286 1.300508 .8005334 -.0152291 2.940222 gdpmetro | 286 278498.9 280178.5 43318 1280517 -------------+--------------------------------------------------------- lngdpmetro | 286 12.1416 .8700275 10.67632 14.06277 season1 | 286 .0979021 .2977031 0 1 season2 | 286 .0979021 .2977031 0 1 season3 | 286 .0979021 .2977031 0 1 season4 | 286 .0979021 .2977031 0 1 -------------+--------------------------------------------------------- season5 | 286 .1013986 .3023849 0 1 season6 | 286 .1013986 .3023849 0 1 season7 | 286 .1013986 .3023849 0 1 season8 | 286 .1013986 .3023849 0 1 season9 | 286 .1013986 .3023849 0 1 -------------+--------------------------------------------------------- season10 | 286 .1013986 .3023849 0 1 bucksdummy | 286 .034965 .1840132 0 1 grizzliesd~y | 286 .034965 .1840132 0 1 hawksdummy | 286 .034965 .1840132 0 1 timberwolv~y | 286 .034965 .1840132 0 1 -------------+--------------------------------------------------------- bobcatsdummy | 286 .020979 .1435652 0 1 pacersdummy | 286 .034965 .1840132 0 1 hornetsdummy | 286 .034965 .1840132 0 1 kingsdummy | 286 .034965 .1840132 0 1 sixersdummy | 286 .034965 .1840132 0 1 -------------+--------------------------------------------------------- nuggetsdummy | 286 .034965 .1840132 0 1 clippersdu~y | 286 .034965 .1840132 0 1 wizardsdummy | 286 .034965 .1840132 0 1 cavaliersd~y | 286 .034965 .1840132 0 1 pistonsdummy | 286 .034965 .1840132 0 1 -------------+--------------------------------------------------------- jazzdummy | 286 .034965 .1840132 0 1 sonicsdummy | 286 .034965 .1840132 0 1 netsdummy | 286 .034965 .1840132 0 1 trailblaze~y | 286 .034965 .1840132 0 1 magicdummy | 286 .034965 .1840132 0 1 -------------+--------------------------------------------------------- sunsdummy | 286 .034965 .1840132 0 1 spursdummy | 286 .034965 .1840132 0 1 warriorsdu~y | 286 .034965 .1840132 0 1 rocketsdummy | 286 .034965 .1840132 0 1 heatdummy | 286 .034965 .1840132 0 1 -------------+--------------------------------------------------------- celticsdummy | 286 .034965 .1840132 0 1 mavericksd~y | 286 .034965 .1840132 0 1 bullsdummy | 286 .034965 .1840132 0 1 lakersdummy | 286 .034965 .1840132 0 1 knicksdummy | 286 .034965 .1840132 0 1 . . * Key variables . describe revenue lnrevenue wins season teamid Variable Storage Display Value name type format label Variable label --------------------------------------------------------------------------------- revenue float %8.0g Team revenue in millions of 1999 $ lnrevenue float %9.0g Natural logarithm of team revenue wins byte %8.0g Wins in previous season including playoff games season byte %8.0g 1 to 10 teamid byte %8.0g 1 to 29 . summarize revenue lnrevenue wins season teamid Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- revenue | 286 95.71404 24.44207 58.49582 187.7212 lnrevenue | 286 4.532293 .2359855 4.068955 5.234958 wins | 286 41.03497 12.43758 9 67 season | 286 5.541958 2.872126 1 10 teamid | 286 14.86014 8.354935 1 29 . . * Pooled OLS . regress lnrev wins season, vce(cluster teamid) noheader (Std. err. adjusted for 29 clusters in teamid) ------------------------------------------------------------------------------ | Robust lnrevenue | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- wins | .0068132 .0018965 3.59 0.001 .0029284 .0106981 season | .0182414 .0033079 5.51 0.000 .0114655 .0250172 _cons | 4.151619 .0965789 42.99 0.000 3.953786 4.349452 ------------------------------------------------------------------------------ . * Fixed effects . regress lnrev wins season i.teamid, vce(cluster teamid) noheader (Std. err. adjusted for 29 clusters in teamid) ------------------------------------------------------------------------------ | Robust lnrevenue | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- wins | .0045238 .0008423 5.37 0.000 .0027985 .0062492 season | .0190451 .0035645 5.34 0.000 .0117436 .0263467 | teamid | 2 | .1629011 .0162562 10.02 0.000 .1296017 .1962005 3 | -.1041217 .015077 -6.91 0.000 -.1350056 -.0732378 4 | -.2915062 .0036219 -80.49 0.000 -.2989253 -.2840872 5 | -.3495826 .0063172 -55.34 0.000 -.3625228 -.3366425 6 | -.3542059 .0090125 -39.30 0.000 -.3726673 -.3357446 7 | -.2574003 .0088441 -29.10 0.000 -.2755166 -.2392841 8 | -.5368562 .0163405 -32.85 0.000 -.5703282 -.5033843 9 | -.4117867 .0044641 -92.24 0.000 -.4209311 -.4026423 10 | -.2925172 .0023584 -124.03 0.000 -.2973482 -.2876862 11 | -.5902926 .0074122 -79.64 0.000 -.6054757 -.5751094 12 | -.5307784 .0088441 -60.02 0.000 -.5488946 -.5126621 13 | -.5864937 .0112867 -51.96 0.000 -.6096135 -.5633739 14 | -.6329163 .0120448 -52.55 0.000 -.6575889 -.6082436 15 | -.5159048 .005138 -100.41 0.000 -.5264294 -.5053801 16 | -.2600773 .0032007 -81.26 0.000 -.2666336 -.2535209 17 | -.3539973 .0080018 -44.24 0.000 -.3703882 -.3376064 18 | -.4301167 .0156666 -27.45 0.000 -.4622083 -.398025 19 | -.5864813 .0168458 -34.81 0.000 -.6209885 -.5519742 20 | -.5487384 .0082545 -66.48 0.000 -.5656469 -.5318299 21 | -.4140961 .0097706 -42.38 0.000 -.4341103 -.394082 22 | -.4169209 .006991 -59.64 0.000 -.4312414 -.4026005 23 | -.6676775 .0088441 -75.49 0.000 -.6857937 -.6495612 24 | -.5182102 .0087598 -59.16 0.000 -.5361539 -.5002664 25 | -.6151022 .0195202 -31.51 0.000 -.6550876 -.5751168 26 | -.5471263 .012129 -45.11 0.000 -.5719715 -.5222812 27 | -.5610469 .0162562 -34.51 0.000 -.5943463 -.5277475 28 | -.6304314 .0163405 -38.58 0.000 -.6639033 -.5969594 29 | -.6937379 .0117921 -58.83 0.000 -.7178929 -.6695829 | _cons | 4.670801 .0459838 101.57 0.000 4.576607 4.764995 ------------------------------------------------------------------------------ . . * Add additional regressors . global xlistmore wins season playoff champ allstars lncitypop . regress lnrev wins season $xlistmore, vce(cluster teamid) note: wins omitted because of collinearity. note: season omitted because of collinearity. Linear regression Number of obs = 286 F(6, 28) = 24.19 Prob > F = 0.0000 R-squared = 0.4564 Root MSE = .17585 (Std. err. adjusted for 29 clusters in teamid) ------------------------------------------------------------------------------ | Robust lnrevenue | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- wins | .0048652 .0014646 3.32 0.002 .001865 .0078653 season | .0180493 .0033125 5.45 0.000 .011264 .0248346 wins | 0 (omitted) season | 0 (omitted) playoff | .030565 .0446834 0.68 0.500 -.0609648 .1220948 champ | .1088688 .0472531 2.30 0.029 .0120752 .2056624 allstars | .0352905 .0177751 1.99 0.057 -.00112 .0717011 lncitypop | .1439873 .0598155 2.41 0.023 .0214608 .2665139 _cons | 3.994532 .0595877 67.04 0.000 3.872472 4.116592 ------------------------------------------------------------------------------ . regress lnrev wins season $xlistmore i.teamid, vce(cluster teamid) note: wins omitted because of collinearity. note: season omitted because of collinearity. Linear regression Number of obs = 286 F(5, 28) = . Prob > F = . R-squared = 0.9007 Root MSE = .07922 (Std. err. adjusted for 29 clusters in teamid) ------------------------------------------------------------------------------ | Robust lnrevenue | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- wins | .0027161 .0007307 3.72 0.001 .0012192 .0042129 season | .0200251 .0030086 6.66 0.000 .0138623 .026188 wins | 0 (omitted) season | 0 (omitted) playoff | .0361872 .0220787 1.64 0.112 -.0090389 .0814132 champ | .0052405 .0176525 0.30 0.769 -.030919 .0414001 allstars | .0355788 .0071512 4.98 0.000 .0209303 .0502274 lncitypop | -.2020894 .0666328 -3.03 0.005 -.3385806 -.0655983 | teamid | 2 | .2863951 .0266945 10.73 0.000 .2317138 .3410764 3 | -.1292118 .0250533 -5.16 0.000 -.1805312 -.0778924 4 | -.4281687 .049685 -8.62 0.000 -.5299438 -.3263936 5 | -.5763522 .0707962 -8.14 0.000 -.7213717 -.4313326 6 | -.5243262 .0576789 -9.09 0.000 -.642476 -.4061763 7 | -.4229366 .0600931 -7.04 0.000 -.5460317 -.2998415 8 | -.7040034 .0802066 -8.78 0.000 -.8682991 -.5397077 9 | -.7783061 .123183 -6.32 0.000 -1.030635 -.5259772 10 | -.5280788 .0809716 -6.52 0.000 -.6939416 -.3622161 11 | -.9542614 .1247777 -7.65 0.000 -1.209857 -.6986659 12 | -.847476 .1215814 -6.97 0.000 -1.096524 -.5984279 13 | -.4917139 .0270793 -18.16 0.000 -.5471832 -.4362445 14 | -.9469774 .1153898 -8.21 0.000 -1.183343 -.710612 15 | -.9861439 .1658419 -5.95 0.000 -1.325856 -.6464322 16 | -.4652562 .0699966 -6.65 0.000 -.6086378 -.3218746 17 | -.6776431 .1178813 -5.75 0.000 -.9191119 -.4361743 18 | -.59368 .0625 -9.50 0.000 -.7217054 -.4656547 19 | -.5453412 .0169707 -32.13 0.000 -.580104 -.5105783 20 | -.8644575 .1115611 -7.75 0.000 -1.09298 -.635935 21 | -.5397559 .0527687 -10.23 0.000 -.6478477 -.4316641 22 | -.7500245 .1227138 -6.11 0.000 -1.001392 -.4986567 23 | -1.120951 .1564917 -7.16 0.000 -1.44151 -.8003925 24 | -.9071175 .1364583 -6.65 0.000 -1.18664 -.6275953 25 | -.9826522 .1384185 -7.10 0.000 -1.26619 -.6991148 26 | -.8059566 .0959408 -8.40 0.000 -1.002482 -.6094307 27 | -.7315995 .0688753 -10.62 0.000 -.8726841 -.590515 28 | -1.049951 .1567056 -6.70 0.000 -1.370948 -.7289537 29 | -1.07684 .1423215 -7.57 0.000 -1.368373 -.7853082 | _cons | 5.17774 .1835393 28.21 0.000 4.801777 5.553703 ------------------------------------------------------------------------------ . . * The following estimates using panel commands . * Declare the individual identifier and the time identifier . xtset teamid season Panel variable: teamid (unbalanced) Time variable: season, 1 to 10 Delta: 1 unit . xtdescribe teamid: 1, 2, ..., 29 n = 29 season: 1, 2, ..., 10 T = 10 Delta(season) = 1 unit Span(season) = 10 periods (teamid*season uniquely identifies each observation) Distribution of T_i: min 5% 25% 50% 75% 95% max 6 10 10 10 10 10 10 Freq. Percent Cum. | Pattern ---------------------------+------------ 28 96.55 96.55 | 1111111111 1 3.45 100.00 | ....111111 ---------------------------+------------ 29 100.00 | XXXXXXXXXX . * Fixed effects estimator . xtreg lnrev wins seasons, fe vce(robust) Fixed-effects (within) regression Number of obs = 286 Group variable: teamid Number of groups = 29 R-squared: Obs per group: Within = 0.3988 min = 6 Between = 0.1439 avg = 9.9 Overall = 0.1615 max = 10 F(2,28) = 33.29 corr(u_i, Xb) = 0.0987 Prob > F = 0.0000 (Std. err. adjusted for 29 clusters in teamid) ------------------------------------------------------------------------------ | Robust lnrevenue | Coefficient std. err. t P>|t| [95% conf. interval] -------------+---------------------------------------------------------------- wins | .0045588 .0008096 5.63 0.000 .0029004 .0062172 seasonsq | .0015499 .0002949 5.26 0.000 .0009458 .0021541 _cons | 4.284879 .0339447 126.23 0.000 4.215346 4.354411 -------------+---------------------------------------------------------------- sigma_u | .20293361 sigma_e | .08889745 rho | .8389979 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . * Random effects estimator . xtreg lnrev wins seasons, re vce(robust) Random-effects GLS regression Number of obs = 286 Group variable: teamid Number of groups = 29 R-squared: Obs per group: Within = 0.3988 min = 6 Between = 0.1442 avg = 9.9 Overall = 0.1620 max = 10 Wald chi2(2) = 68.63 corr(u_i, X) = 0 (assumed) Prob > chi2 = 0.0000 (Std. err. adjusted for 29 clusters in teamid) ------------------------------------------------------------------------------ | Robust lnrevenue | Coefficient std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- wins | .004626 .0008003 5.78 0.000 .0030574 .0061945 seasonsq | .0015478 .0002942 5.26 0.000 .0009711 .0021245 _cons | 4.279819 .0486866 87.91 0.000 4.184395 4.375243 -------------+---------------------------------------------------------------- sigma_u | .19978447 sigma_e | .08889745 rho | .83472772 (fraction of variance due to u_i) ------------------------------------------------------------------------------ . . ********** CLOSE OUTPUT . log close name: log: c:\Users\ccameron\Dropbox\Desktop\TEACHING\190\Methods\panel.txt log type: text closed on: 21 Mar 2023, 14:08:19 ---------------------------------------------------------------------------------