Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error message after running xttest2 and xtcsd: how to restrict the analysis to those periods when all panels are observed?

    Hi all. I have panel data on the spending with government ads (my dependent variable: ln_mun_spend_ad_2) by Brazilian municipalities (N = 66,840) from 2005 to 2016.

    Code:
    xtreg ln_mun_spend_ad_2 pref_incumb_term_bef party_pres_coal same_party_mayor_gov party_pres ln_r_pib_2_cap ln_r_receitas_totais_2 i_eleitores_analf_perc i_eleitores_ens_sup_perc perc_pop_bf i_idhm i_ideo_na i_fragf i_comp i_pol_pi ln_i_pop_total_int i.year, fe robust
    I need to run some tests to verify whether the use of OLS with panel-corrected standard errors (PCSE) is warranted. More precisely, I want to run the following tests:


    a) Breusch and Pagan LM test for cross-sectional correlation (xttest2)

    b) Cross-sectional Dependence test (xtcsd, frees)


    I have been unable to run both tests. After running “xttest2” and “xtcsd, frees”, I obtain the following error: r(2000); no observations

    After doing some searches on the Forum, I found a comment suggesting that it is possible to get around the error by restricting the analysis to those periods when all panels are observed.

    Question: Can someone help me run “xtreg, fe” by restricting the analysis to those periods when all panels are observed?

    Part of my data follows below. Time ID is “year” and panel ID is “ibge_mun_code”.

    Thank you


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long(year ibge_mun_code) str38 municipio float(ln_mun_spend_ad_2 ln_r_pib_2_cap) double i_eleitores_analf_perc float perc_pop_bf double i_idhm float ln_i_pop_total_int
    2005 1100015 "Alta Floresta D'Oeste (RO)"             0  9.305279  .10766220465302467  .21114953 .5620000064373016 10.262176
    2006 1100015 "Alta Floresta D'Oeste (RO)"             0  9.271289   .1101791188120842   .1974487  .578000009059906 10.275224
    2007 1100015 "Alta Floresta D'Oeste (RO)"             0  9.432512  .11014299094676971  .23078646  .593500018119812 10.195822
    2008 1100015 "Alta Floresta D'Oeste (RO)"             0   9.72454  .11010686308145523   .2487692  .609000027179718 10.109567
    2009 1100015 "Alta Floresta D'Oeste (RO)"             0  9.723163  .10938729718327522   .2536339              .625 10.100451
    2010 1100015 "Alta Floresta D'Oeste (RO)"             0  9.687963  .10866773128509521   .2444115  .640999972820282  10.09786
    2011 1100015 "Alta Floresta D'Oeste (RO)"             0  9.695524   .1058625690639019   .2291976 .6567999720573425 10.095264
    2012 1100015 "Alta Floresta D'Oeste (RO)"             0    9.8049  .10305740684270859  .26037642 .6725999712944031  10.08868
    2013 1100015 "Alta Floresta D'Oeste (RO)"             0  9.717508  .10062960162758827  .03789645  .688400000333786 10.155335
    2014 1100015 "Alta Floresta D'Oeste (RO)"             0  9.759888  .09820179641246796  .03824263  .704200029373169 10.152377
    2015 1100015 "Alta Floresta D'Oeste (RO)"             0   9.77035  .09614992514252663  .03858785 .7200000286102295 10.149487
    2016 1100015 "Alta Floresta D'Oeste (RO)"             0  9.838906   .0940980538725853  .03893201   .73580002784729  10.14667
    2005 1100023 "Ariquemes (RO)"                         0  9.716696  .07531549409031868  .13862003 .6290000081062317  11.35077
    2006 1100023 "Ariquemes (RO)"                         0  9.717894   .0737328827381134    .159139 .6439999938011169  11.37279
    2007 1100023 "Ariquemes (RO)"                         0  9.823101  .07285322993993759  .15235797 .6584999859333038 11.359215
    2008 1100023 "Ariquemes (RO)"                         0  9.941903  .07197357714176178  .13410813 .6729999780654907 11.345465
    2009 1100023 "Ariquemes (RO)"                         0   9.95055  .06961370259523392  .18496394             .6875 11.356751
    2010 1100023 "Ariquemes (RO)"                         0 10.044492  .06725382804870605  .17534865 .7020000219345093  11.39138
    2011 1100023 "Ariquemes (RO)"                         0 10.138992  .06481249816715717  .15502894 .7166000008583069  11.42486
    2012 1100023 "Ariquemes (RO)"                         0 10.100327  .06237116828560829  .17124005 .7311999797821045  11.43763
    2013 1100023 "Ariquemes (RO)"                         0 10.009933  .05384931340813637  .05504152 .7457999885082245 11.525536
    2014 1100023 "Ariquemes (RO)"                         0  9.997657 .045327458530664444   .0502236 .7603999972343445 11.541124
    2015 1100023 "Ariquemes (RO)"                   13.0363  9.940124  .04414767399430275  .04560301 .7750000059604645 11.555995
    2016 1100023 "Ariquemes (RO)"                 11.769658   9.93437 .042967889457941055   .0411347 .7896000146865845 11.570212
    2005 1100031 "Cabixi (RO)"                            0  9.429081  .11974328756332397  .04115115 .5689999759197235  8.914088
    2006 1100031 "Cabixi (RO)"                            0  9.353375  .11714285612106323  .19687374 .5849999785423279  8.912069
    2007 1100031 "Cabixi (RO)"                            0  9.401649  .11443133652210236  .24595013 .6014999747276306  8.867709
    2008 1100031 "Cabixi (RO)"                            0  9.599612  .11171981692314148   .2611775 .6179999709129333   8.82129
    2009 1100031 "Cabixi (RO)"                            0  9.710767  .10793731361627579  .23838685 .6339999735355377  8.809116
    2010 1100031 "Cabixi (RO)"                            0  9.687034   .1041548103094101   .2132239 .6499999761581421  8.773075
    2011 1100031 "Cabixi (RO)"                            0  9.765113  .10091203451156616   .2589616 .6661999821662903  8.735686
    2012 1100031 "Cabixi (RO)"                            0   9.97718  .09766925871372223  .27641878 .6823999881744385  8.721276
    2013 1100031 "Cabixi (RO)"                            0  9.829364  .09273817762732506   2.817552 .6985999941825867  8.778788
    2014 1100031 "Cabixi (RO)"                            0  9.941707  .08780709654092789   2.597914 .7148000001907349 8.7677965
    2015 1100031 "Cabixi (RO)"                            0  9.877945  .08408211916685104  2.3726199 .7310000061988831  8.756997
    2016 1100031 "Cabixi (RO)"                            0   9.96187   .0803571417927742   2.141358 .7472000122070313  8.746557
    2005 1100049 "Cacoal (RO)"                            0  9.842319   .0633725505322218   .2362873 .6424999833106995  11.23833
    2006 1100049 "Cacoal (RO)"                            0  9.784699    .062248345464468   .2231687 .6579999923706055 11.244026
    2007 1100049 "Cacoal (RO)"                            0  9.821217  .06236306205391884  .19099584 .6730000078678131 11.255993
    2008 1100049 "Cacoal (RO)"                            0   9.88276 .062477778643369675  .17786182 .6880000233650208  11.26783
    2009 1100049 "Cacoal (RO)"                            0   9.89464  .06126479059457779  .20850334  .703000009059906  11.27308
    2010 1100049 "Cacoal (RO)"                            0  10.02106 .060051802545785904   .2088128 .7179999947547913 11.274884
    2011 1100049 "Cacoal (RO)"                            0 10.015588  .05884280055761337  .21075495 .7330999970436096 11.276684
    2012 1100049 "Cacoal (RO)"                            0   10.0406  .05763379856944084  .20871045  .748199999332428 11.281372
    2013 1100049 "Cacoal (RO)"                            0  9.947203 .055785857141017914 .018098598 .7633000016212463 11.360508
    2014 1100049 "Cacoal (RO)"                            0  10.02432 .053937915712594986 .014938306 .7784000039100647 11.368546
    2015 1100049 "Cacoal (RO)"                            0  9.992704  .05342475697398186 .011865729 .7935000061988831 11.376258
    2016 1100049 "Cacoal (RO)"                            0 10.006007  .05291159823536873 .008841904 .8086000084877014 11.383694
    2005 1100056 "Cerejeiras (RO)"                        0  9.547071  .09568153321743011  .21611194  .617000013589859   9.76227
    2006 1100056 "Cerejeiras (RO)"                        0  9.487854  .09415536373853683  .25251234 .6320000290870667  9.753536
    2007 1100056 "Cerejeiras (RO)"                        0  9.597978  .09358843043446541  .24530855 .6470000147819519   9.74091
    2008 1100056 "Cerejeiras (RO)"                        0  9.709453  .09302149713039398  .20608914 .6620000004768372  9.728181
    2009 1100056 "Cerejeiras (RO)"                        0  9.807871  .09014618396759033  .22993623 .6769999861717224  9.718482
    2010 1100056 "Cerejeiras (RO)"                        0  9.892015  .08727087080478668  .22651966 .6919999718666077  9.727943
    2011 1100056 "Cerejeiras (RO)"                        0  9.978033  .08606978878378868   .2001299 .7069999873638153  9.737374
    2012 1100056 "Cerejeiras (RO)"                        0 10.243877  .08486870676279068  .20614764  .722000002861023  9.732224
    2013 1100056 "Cerejeiras (RO)"                        0  10.10684  .08326612412929535   .3225985 .7369999885559082  9.800403
    2014 1100056 "Cerejeiras (RO)"                        0  10.15138  .08166354149580002   .3191029 .7519999742507935  9.798849
    2015 1100056 "Cerejeiras (RO)"                        0 10.064932  .08027233928442001   .3155788 .7669999897480011  9.797349
    2016 1100056 "Cerejeiras (RO)"                        0 10.031406  .07888113707304001   .3122112 .7820000052452087  9.795847
    2005 1100064 "Colorado do Oeste (RO)"                 0  9.443193  .10810985043644905   .1792088 .6150000095367432  9.846017
    2006 1100064 "Colorado do Oeste (RO)"                 0  9.442405  .10889976471662521   .2814851 .6290000081062317  9.816949
    2007 1100064 "Colorado do Oeste (RO)"                 0  9.487169  .10325523093342781  .28540948 .6430000066757202  9.813508
    2008 1100064 "Colorado do Oeste (RO)"                 0  9.563161  .09761069715023041   .2465415 .6570000052452087  9.810056
    2009 1100064 "Colorado do Oeste (RO)"                 0  9.646424  .09463351219892502   .2390304 .6710000038146973  9.788189
    2010 1100064 "Colorado do Oeste (RO)"                 0  9.677796  .09165632724761963   .2044248 .6850000023841858  9.802562
    2011 1100064 "Colorado do Oeste (RO)"                 0  9.667386   .0888901837170124  .18682517 .6990000009536743   9.81673
    2012 1100064 "Colorado do Oeste (RO)"                 0  9.697151  .08612404018640518  .18239097 .7129999995231628  9.803281
    2013 1100064 "Colorado do Oeste (RO)"                 0  9.669966  .08469833061099052  .17102657 .7269999980926514  9.862144
    2014 1100064 "Colorado do Oeste (RO)"                 0  9.737904  .08327262103557587  .15662333 .7409999966621399  9.852247
    2015 1100064 "Colorado do Oeste (RO)"                 0   9.68777  .08158290386199951  .14189297 .7549999952316284  9.842516
    2016 1100064 "Colorado do Oeste (RO)"                 0  9.707776  .07989318668842316  .12683083 .7689999938011169  9.833012
    2005 1100072 "Corumbiara (RO)"                        0  9.544194  .11312105134129524  .09593479 .5069999992847443  9.166284
    2006 1100072 "Corumbiara (RO)"                        0   9.50151  .11109161376953125   .2104368  .527999997138977  9.149422
    2007 1100072 "Corumbiara (RO)"                        0  9.486901  .10667641833424568   .2485133 .5494999885559082  9.167954
    2008 1100072 "Corumbiara (RO)"                        0    9.6949  .10226122289896011  .29320768 .5709999799728394  9.186151
    2009 1100072 "Corumbiara (RO)"                        0  9.877796  .10257838666439056   .2841942 .5919999778270721  9.177817
    2010 1100072 "Corumbiara (RO)"                        0  9.836733  .10289555042982101  .30860695 .6129999756813049  9.123365
    2011 1100072 "Corumbiara (RO)"                        0 10.067858  .09920287877321243  .30918545 .6341999769210815  9.065892
    2012 1100072 "Corumbiara (RO)"                        0 10.215846  .09551020711660385   .3042204 .6553999781608582  9.051345
    2013 1100072 "Corumbiara (RO)"                        0 10.059046   .0935647040605545  .25398406 .6765999794006348  9.108972
    2014 1100072 "Corumbiara (RO)"                        0 10.110238  .09161920100450516  .23830834 .6977999806404114  9.098067
    2015 1100072 "Corumbiara (RO)"                        0 10.041005  .08988036960363388   .2222348  .718999981880188  9.087269
    2016 1100072 "Corumbiara (RO)"                        0 10.205288   .0881415382027626   .2057378 .7401999831199646 9.0766945
    2005 1100080 "Costa Marques (RO)"                     0  9.254727  .05580459162592888 .014803066 .5485000014305115 9.3368845
    2006 1100080 "Costa Marques (RO)"                     0  9.155224  .05357594043016434  .28887942 .5609999895095825  9.370331
    2007 1100080 "Costa Marques (RO)"                     0  9.219712   .0534562598913908  .24902754  .573500007390976 9.4614105
    2008 1100080 "Costa Marques (RO)"                     0  9.282464 .053336579352617264   .2061118 .5860000252723694  9.544882
    2009 1100080 "Costa Marques (RO)"                     0  9.299714 .052151698619127274    .324661 .5985000133514404  9.578588
    2010 1100080 "Costa Marques (RO)"                     0  9.331849  .05096681788563728   .3042776 .6110000014305115    9.5636
    2011 1100080 "Costa Marques (RO)"                     0  9.393367 .050266414880752563   .2847465 .6234999895095825  9.548454
    2012 1100080 "Costa Marques (RO)"                     0  9.424099 .049566011875867844   .3065831 .6359999775886536  9.571854
    2013 1100080 "Costa Marques (RO)"                     0  9.377788  .04827026650309563   .1807229  .648499995470047  9.671114
    2014 1100080 "Costa Marques (RO)"                     0  9.409121  .04697452113032341  .14558986 .6610000133514404  9.696341
    2015 1100080 "Costa Marques (RO)"                     0  9.388285  .04674307443201542   .1122455 .6735000014305115  9.720225
    2016 1100080 "Costa Marques (RO)"                     0  9.401087  .04651162773370743  .08050027 .6859999895095825   9.74279
    2005 1100098 "Espigão D'Oeste (RO)"          13.245784  9.549481  .09984136372804642  .11186478 .5864999890327454  10.21369
    2006 1100098 "Espigão D'Oeste (RO)"           13.15068  9.468072  .09851378202438354   .1905004 .6039999723434448 10.224085
    2007 1100098 "Espigão D'Oeste (RO)"           13.14925  9.526738  .09604356065392494  .21553688 .6209999918937683 10.243097
    2008 1100098 "Espigão D'Oeste (RO)"          13.116055  9.637101  .09357333928346634   .2205682 .6380000114440918 10.261756
    2009 1100098 "Espigão D'Oeste (RO)"          12.494383  9.678282  .09144579246640205  .26291016 .6550000011920929  10.27132
    2010 1100098 "Espigão D'Oeste (RO)"          12.899014  9.686978  .08931824564933777  .29277146  .671999990940094  10.27253
    2011 1100098 "Espigão D'Oeste (RO)"          11.916635  9.731402  .08961779996752739  .27852777 .6890999972820282 10.273774
    2012 1100098 "Espigão D'Oeste (RO)"                  0  9.745947  .08991735428571701   .2722601 .7062000036239624 10.281548
    2013 1100098 "Espigão D'Oeste (RO)"                  0  9.731688   .0894230380654335  .15388498 .7233000099658966  10.36404
    2014 1100098 "Espigão D'Oeste (RO)"                  0   9.73935     .08892872184515   .1557712 .7404000163078308  10.37496
    2015 1100098 "Espigão D'Oeste (RO)"                  0  9.673049  .08753702789545059   .1576656  .757500022649765  10.38545
    2016 1100098 "Espigão D'Oeste (RO)"                  0  9.717708  .08614533394575119  .15957446 .7746000289916992 10.395497
    2005 1100106 "Guajará-Mirim (RO)"                    0  9.607971  .06133279390633106  .13427545 .6150000095367432 10.632653
    2006 1100106 "Guajará-Mirim (RO)"                    0  9.556262 .061153311282396317   .2195713 .6230000257492065 10.647375
    2007 1100106 "Guajará-Mirim (RO)"                    0  9.669838  .06194023974239826  .23354554 .6315000057220459 10.628884
    2008 1100106 "Guajará-Mirim (RO)"                    0  9.903832  .06272716820240021   .2288054 .6399999856948853  10.61007
    2009 1100106 "Guajará-Mirim (RO)"                    0  9.915037   .0639469102025032  .23543987  .648499995470047 10.615505
    2010 1100106 "Guajará-Mirim (RO)"                    0  9.981277   .0651666522026062  .26569605 .6570000052452087  10.62978
    2011 1100106 "Guajará-Mirim (RO)"                    0  10.08315  .06651651486754417  .28222921 .6653999984264374 10.643852
    2012 1100106 "Guajará-Mirim (RO)"                    0  9.693651  .06786637753248215   .3021895  .673799991607666 10.650223
    2013 1100106 "Guajará-Mirim (RO)"                    0  9.714266  .06272210739552975  .16848408 .6821999847888947 10.731188
    2014 1100106 "Guajará-Mirim (RO)"                    0   9.70814  .05757783725857735  .14473087 .6905999779701233   10.7408
    2015 1100106 "Guajará-Mirim (RO)"                    0  9.652151  .05828039534389973  .12146166 .6990000009536743 10.750042
    2016 1100106 "Guajará-Mirim (RO)"                    0  9.663713  .05898295342922211   .0987077 .7074000239372253 10.758924
    2005 1100114 "Jaru (RO)"                              0  9.863532   .1109892874956131   .2103331  .601500004529953 10.930245
    2006 1100114 "Jaru (RO)"                              0  9.900357  .11301284283399582   .2433413 .6190000176429749  10.93742
    2007 1100114 "Jaru (RO)"                              0  9.999416  .11286825686693192   .2258521 .6365000009536743  10.91687
    2008 1100114 "Jaru (RO)"                              0  9.984526  .11272367089986801   .2239088 .6539999842643738 10.895905
    2009 1100114 "Jaru (RO)"                              0  9.960999  .10984018445014954   .2082198 .6714999973773956 10.895683
    2010 1100114 "Jaru (RO)"                              0 10.022007  .10695669800043106   .2281481 .6890000104904175 10.876405
    2011 1100114 "Jaru (RO)"                              0  10.05625   .1052943617105484     .24615 .7064999938011169 10.856747
    2012 1100114 "Jaru (RO)"                              0 10.155672  .10363202542066574   .2372066 .7239999771118164  10.85447
    2013 1100114 "Jaru (RO)"                              0 10.089938  .10140101611614227   .2170261 .7414999902248383 10.925884
    2014 1100114 "Jaru (RO)"                              0  10.08128   .0991700068116188   .2070991 .7590000033378601 10.927178
    2015 1100114 "Jaru (RO)"                              0 10.044767  .09658277407288551  .19720837  .776500016450882 10.928417
    2016 1100114 "Jaru (RO)"                              0 10.066646  .09399554133415222   .1873992 .7940000295639038 10.929637
    2005 1100122 "Ji-Paraná (RO)"                 9.607875  9.790223  .06847934797406197  .07617464 .6389999985694885 11.630166
    2006 1100122 "Ji-Paraná (RO)"                        0  9.791108  .06665445119142532  .15199246 .6539999842643738 11.639144
    2007 1100122 "Ji-Paraná (RO)"                        0  9.883949  .06508449465036392  .19218415 .6689999997615814 11.626968
    2008 1100122 "Ji-Paraná (RO)"                        0  10.01283  .06351453810930252  .17337658 .6840000152587891 11.614642
    2009 1100122 "Ji-Paraná (RO)"                        0 10.059878 .061462750658392906   .1951716 .6990000009536743 11.617375
    2010 1100122 "Ji-Paraná (RO)"                        0 10.097435  .05941096320748329     .18483 .7139999866485596 11.645584
    2011 1100122 "Ji-Paraná (RO)"                        0 10.109777  .05803472921252251  .15155543 .7290000021457672 11.673027
    2012 1100122 "Ji-Paraná (RO)"                        0  10.16699  .05665849521756172  .15234733 .7440000176429749  11.67922
    2013 1100122 "Ji-Paraná (RO)"                        0  10.05269  .05476877838373184   .0238311 .7590000033378601  11.75999
    2014 1100122 "Ji-Paraná (RO)"                        0 10.091246  .05287906154990196  .02177311 .7739999890327454 11.769442
    2015 1100122 "Ji-Paraná (RO)"                        0 10.019432   .0441936906427145 .019782394  .789000004529953 11.778507
    2016 1100122 "Ji-Paraná (RO)"                        0 10.029907  .03550831973552704 .017832167 .8040000200271606 11.787218
    2005 1100130 "Machadinho D'Oeste (RO)"                0  9.415211  .07875625416636467  .08241125 .5225000083446503 10.262874
    2006 1100130 "Machadinho D'Oeste (RO)"        11.000458  9.239007  .07447850704193115   .2308236 .5370000004768372 10.299273
    2007 1100130 "Machadinho D'Oeste (RO)"        10.889117  9.246759  .07313994318246841  .19087914 .5519999861717224 10.340516
    2008 1100130 "Machadinho D'Oeste (RO)"                0  9.394079  .07180137932300568  .18085304 .5669999718666077 10.380157
    2009 1100130 "Machadinho D'Oeste (RO)"                0   9.40458  .07109542191028595  .25513434 .5814999938011169  10.40907
    2010 1100130 "Machadinho D'Oeste (RO)"                0  9.435685  .07038946449756622  .23570174 .5960000157356262 10.388041
    2011 1100130 "Machadinho D'Oeste (RO)"                0  9.497325  .07068001106381416  .23760226 .6107000112533569 10.366592
    2012 1100130 "Machadinho D'Oeste (RO)"                0  9.578097   .0709705576300621  .28765854 .6254000067710876 10.386006
    2013 1100130 "Machadinho D'Oeste (RO)"                0  9.542055  .06472627632319927   .3521735 .6401000022888184 10.481028
    2014 1100130 "Machadinho D'Oeste (RO)"                0  9.526844  .05848199501633644   .3157201 .6547999978065491 10.502654
    2015 1100130 "Machadinho D'Oeste (RO)"                0  9.466866 .057677119970321655  .28097504 .6694999933242798 10.523176
    2016 1100130 "Machadinho D'Oeste (RO)"                0  9.512919  .05687224492430687  .24784295 .6841999888420105  10.54268
    2005 1100148 "Nova Brasilândia D'Oeste (RO)"         0  9.352173  .07223722711205482  .22589855 .5509999990463257  9.790431
    2006 1100148 "Nova Brasilândia D'Oeste (RO)"         0  9.303113  .07275743037462234  .27225772 .5690000057220459  9.798405
    2007 1100148 "Nova Brasilândia D'Oeste (RO)"         0  9.524134  .07275532186031342   .2668686 .5875000059604645  9.788582
    2008 1100148 "Nova Brasilândia D'Oeste (RO)"         0  9.657461  .07275321334600449   .2462471 .6060000061988831  9.778661
    2009 1100148 "Nova Brasilândia D'Oeste (RO)"         0  9.595572  .07069846615195274   .3290202 .6245000064373016  9.781207
    2010 1100148 "Nova Brasilândia D'Oeste (RO)"         0  9.533153    .068643718957901   .3059074 .6430000066757202   9.84108
    2011 1100148 "Nova Brasilândia D'Oeste (RO)"         0  9.498263  .06804246827960014   .3097621 .6613999903202057   9.89762
    2012 1100148 "Nova Brasilândia D'Oeste (RO)"         0  9.574607  .06744121760129929   .3698155 .6797999739646912  9.898023
    2013 1100148 "Nova Brasilândia D'Oeste (RO)"         0 9.5086155   .0662253238260746   .1866337  .698199987411499  9.972407
    2014 1100148 "Nova Brasilândia D'Oeste (RO)"         0  9.551651  .06500943005084991   .1582911 .7166000008583069  9.976319
    2015 1100148 "Nova Brasilândia D'Oeste (RO)"         0  9.504325  .06417907774448395  .13032605 .7350000143051147  9.980078
    2016 1100148 "Nova Brasilândia D'Oeste (RO)"         0  9.561147  .06334872543811798  .10258422 .7534000277519226  9.983685
    2005 1100155 "Ouro Preto do Oeste (RO)"               .  9.502101  .08323891088366508  .06646711 .6074999868869781 10.615383
    2006 1100155 "Ouro Preto do Oeste (RO)"               0  9.470016   .0828973576426506  .11002823  .621999979019165 10.614843
    2007 1100155 "Ouro Preto do Oeste (RO)"               0  9.569957  .08326895162463188   .1633366 .6369999945163727 10.569726
    2008 1100155 "Ouro Preto do Oeste (RO)"               0  9.788091  .08364054560661316  .21590114 .6520000100135803 10.522504
    2009 1100155 "Ouro Preto do Oeste (RO)"               0  9.754069  .08159635961055756  .23420013 .6669999957084656 10.511213
    2010 1100155 "Ouro Preto do Oeste (RO)"               0  9.861339  .07955217361450195   .2102491 .6819999814033508 10.524413
    2011 1100155 "Ouro Preto do Oeste (RO)"               0  9.846779  .07811447978019714   .1907326 .6968999803066254 10.537468
    2012 1100155 "Ouro Preto do Oeste (RO)"               0  9.834895  .07667678594589233    .174964 .7117999792098999 10.531616
    2013 1100155 "Ouro Preto do Oeste (RO)"               0  9.762466   .0748552456498146   .0454126 .7266999781131744 10.599107
    2014 1100155 "Ouro Preto do Oeste (RO)"               0   9.77917  .07303370535373688  .03981505  .741599977016449 10.596885
    2015 1100155 "Ouro Preto do Oeste (RO)"               0  9.732309  .07195230945944786  .03418996 .7564999759197235 10.594733
    2016 1100155 "Ouro Preto do Oeste (RO)"               0  9.789726  .07087091356515884 .028539157  .771399974822998 10.592627
    2005 1100189 "Pimenta Bueno (RO)"                     0  9.822588  .06823012605309486    .149304 .6414999961853027 10.356663
    2006 1100189 "Pimenta Bueno (RO)"                     0  9.805333  .06822139769792557   .1674041 .6549999713897705  10.35504
    2007 1100189 "Pimenta Bueno (RO)"                     0    9.8017  .06724873557686806  .15474255 .6689999997615814 10.392344
    2008 1100189 "Pimenta Bueno (RO)"                     0  9.928703  .06627607345581055  .18628524 .6830000281333923 10.428305
    2009 1100189 "Pimenta Bueno (RO)"                     0  9.997663  .06495621800422668   .1807027 .6965000033378601 10.433645
    2010 1100189 "Pimenta Bueno (RO)"                     0 10.076763  .06363636255264282   .1875993 .7099999785423279 10.433586
    2011 1100189 "Pimenta Bueno (RO)"                     0 10.122095   .0628596618771553   .1573232 .7236999869346619 10.433557
    2012 1100189 "Pimenta Bueno (RO)"                     0 10.192755 .062082961201667786  .13675113 .7373999953269958  10.43808
    2013 1100189 "Pimenta Bueno (RO)"                     0  10.15042  .06028470955789089   .1615366 .7511000037193298 10.517023
    2014 1100189 "Pimenta Bueno (RO)"                     0  10.18396    .058486457914114  .14133763 .7648000121116638  10.52487
    2015 1100189 "Pimenta Bueno (RO)"                     0 10.153605  .05654974654316902  .12148113 .7785000205039978 10.532416
    2016 1100189 "Pimenta Bueno (RO)"                     0 10.184254 .054613035172224045  .10194252 .7922000288963318 10.539694
    2005 1100205 "Porto Velho (RO)"               15.488406  9.859941  .03645786643028259   .1189756 .6744999885559082  12.83179
    2006 1100205 "Porto Velho (RO)"                 15.1271  9.884409  .03672008961439133  .16222367 .6869999766349792 12.850487
    2007 1100205 "Porto Velho (RO)"               14.893983  9.932241  .03666204214096069   .1546731 .6990000009536743 12.848134
    2008 1100205 "Porto Velho (RO)"                14.69631 10.040357  .03660399466753006  .14365284 .7110000252723694  12.84578
    2009 1100205 "Porto Velho (RO)"               15.813148 10.250077 .035516729578375816   .2006666 .7235000133514404 12.855344
    2010 1100205 "Porto Velho (RO)"                       0  10.41038  .03442946448922157  .17573544 .7360000014305115 12.922154
    2011 1100205 "Porto Velho (RO)"                       0 10.487627 .028512817807495594  .15778965 .7482999861240387 12.984782
    2012 1100205 "Porto Velho (RO)"                       0 10.487017 .022596171125769615  .15923615 .7605999708175659  13.00065
    end

  • #2
    Bruno:
    I'm far from my desktop at the moment, so I cannot test, but I would add an -if- clause like:
    Code:
    if year[_N]==12
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you, Carlo. I added the clause and tried to run the model, but obtained the following error message: r(2001); insufficient observations

      Code:
      xtreg ln_mun_spend_ad_2 pref_incumb_term_bef party_pres_coal same_party_mayor_gov party_pres ln_r_pib_2_cap ln_r_receitas_totais_2 i_eleitores_analf_perc i_eleitores_ens_sup_perc perc_pop_bf i_idhm i_ideo_na i_fragf i_comp i_pol_pi ln_i_pop_total_int i.year if year[_N]==12, fe robust


      Comment


      • #4
        Bruno:
        youe example does not allow to replicate your issue.
        That said. you may want to consider what follows:
        Code:
        . bysort ibge_mun_code (year): egen wanted=count(year)
        
        . xtreg ln_mun_spend_ad_2   ln_r_pib_2_cap  i_eleitores_analf_perc perc_pop_bf i_idhm    ln_i_pop_total_int i.year if wanted==12, fe robust
        
        Fixed-effects (within) regression               Number of obs     =        191
        Group variable: ibge_mun_c~e                    Number of groups  =         16
        
        R-squared:                                      Obs per group:
             Within  = 0.1717                                         min =         11
             Between = 0.0239                                         avg =       11.9
             Overall = 0.0014                                         max =         12
        
                                                        F(15,15)          =          .
        corr(u_i, Xb) = -0.9331                         Prob > F          =          .
        
                                           (Std. err. adjusted for 16 clusters in ibge_mun_code)
        ----------------------------------------------------------------------------------------
                               |               Robust
             ln_mun_spend_ad_2 | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
        -----------------------+----------------------------------------------------------------
                ln_r_pib_2_cap |  -.3467479   2.770718    -0.13   0.902    -6.252394    5.558899
        i_eleitores_analf_perc |  -230.3125   149.4618    -1.54   0.144    -548.8827    88.25769
                   perc_pop_bf |  -1.104388   .7596841    -1.45   0.167    -2.723616    .5148401
                        i_idhm |   -56.7589   51.83169    -1.10   0.291    -167.2355    53.71773
            ln_i_pop_total_int |  -4.486947   7.020318    -0.64   0.532     -19.4504    10.47651
                               |
                          year |
                         2006  |   .7853941   1.327055     0.59   0.563    -2.043157    3.613946
                         2007  |   1.387593   1.734706     0.80   0.436    -2.309844     5.08503
                         2008  |   1.319075   1.928524     0.68   0.504    -2.791478    5.429627
                         2009  |   1.808758   2.439529     0.74   0.470    -3.390975     7.00849
                         2010  |   2.328889   2.990492     0.78   0.448    -4.045195    8.702972
                         2011  |   2.831786   3.523246     0.80   0.434    -4.677835    10.34141
                         2012  |   2.671141   3.567995     0.75   0.466    -4.933861    10.27614
                         2013  |   3.295407   4.487966     0.73   0.474    -6.270466    12.86128
                         2014  |   3.519288   4.968167     0.71   0.490    -7.070111    14.10869
                         2015  |   4.754237   5.577213     0.85   0.407    -7.133312    16.64178
                         2016  |   5.124076   6.138191     0.83   0.417    -7.959168    18.20732
                               |
                         _cons |   104.4627   91.53252     1.14   0.272    -90.63427    299.5596
        -----------------------+----------------------------------------------------------------
                       sigma_u |  5.9894961
                       sigma_e |  2.3105144
                           rho |  .87046475   (fraction of variance due to u_i)
        ----------------------------------------------------------------------------------------
        
        . xttest2
        
        Correlation matrix of residuals is singular.
        not possible with test
        r(131);
        
        . xtcsd, frees
         
          Frees' test of cross sectional independence =     3.754
        |--------------------------------------------------------|
          Critical values from Frees' Q distribution
                              alpha = 0.10 :   0.2333
                              alpha = 0.05 :   0.3103
                              alpha = 0.01 :   0.4649
        
        .
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Thank you Carlo for coming up with the code. I provided the code line for all the variables in my model rather than the subsample of variables that I posted in this thread. Maybe that's why you couldn't replicate the problem. I apologize for that.

          In fact, your code works for the sample I posted. Unfortunately, when I used it to run xttest2 in my complete data (and using only the variables that you used in your code line with "if wanted==12"), I got the following error: r(900); no room to add more variables. Up to 5,000 variables are currently allowed, although you could reset the maximum using set maxvar; see help memory.

          Thus, I ran "set maxvar 30000, perm", closed Stata, opened my dataset, ran the command line below and ran xttest2. Then, I got this error: r(2000); no observations.


          Code:
           xtreg ln_mun_spend_ad_2 ln_r_pib_2_cap i_eleitores_analf_perc perc_pop_bf i_idhm ln_i_pop_total_int i.year if wanted==12, fe robust
          
          Fixed-effects (within) regression               Number of obs     =     65,529
          Group variable: ibge_mun_c~e                    Number of groups  =      5,558
          
          R-squared:                                      Obs per group:
               Within  = 0.0021                                         min =          4
               Between = 0.1853                                         avg =       11.8
               Overall = 0.1174                                         max =         12
          
                                                          F(16,5557)        =       6.02
          corr(u_i, Xb) = -0.5601                         Prob > F          =     0.0000
          
                                          (Std. err. adjusted for 5,558 clusters in ibge_mun_code)
          ----------------------------------------------------------------------------------------
                                 |               Robust
               ln_mun_spend_ad_2 | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
          -----------------------+----------------------------------------------------------------
                  ln_r_pib_2_cap |   .0457482   .1012422     0.45   0.651    -.1527262    .2442226
          i_eleitores_analf_perc |   .4186321   1.979392     0.21   0.833     -3.46175    4.299014
                     perc_pop_bf |   .0067887    .021608     0.31   0.753    -.0355715    .0491489
                          i_idhm |  -4.072972   1.558747    -2.61   0.009    -7.128726   -1.017218
              ln_i_pop_total_int |   -.517393   .2774769    -1.86   0.062    -1.061356    .0265703
                                 |
                            year |
                           2006  |   .2643768   .0544992     4.85   0.000      .157537    .3712166
                           2007  |   .2843539   .0681236     4.17   0.000      .150805    .4179029
                           2008  |   .3457128    .084543     4.09   0.000     .1799754    .5114502
                           2009  |    .362196   .1007697     3.59   0.000      .164648    .5597439
                           2010  |   .5628347   .1251969     4.50   0.000     .3173998    .8082697
                           2011  |     .65992   .1444098     4.57   0.000     .3768203    .9430197
                           2012  |   .6398233   .1627128     3.93   0.000     .3208427    .9588039
                           2013  |    .727189   .1812433     4.01   0.000     .3718813    1.082497
                           2014  |   .8526422   .2042671     4.17   0.000     .4521989    1.253086
                           2015  |   .9221954   .2210452     4.17   0.000     .4888603     1.35553
                           2016  |   .7711481   .2390513     3.23   0.001     .3025141    1.239782
                                 |
                           _cons |   8.596345   3.135437     2.74   0.006     2.449662    14.74303
          -----------------------+----------------------------------------------------------------
                         sigma_u |   3.981815
                         sigma_e |  2.7020676
                             rho |  .68469671   (fraction of variance due to u_i)
          ----------------------------------------------------------------------------------------

          Comment


          • #6
            Code:
            -------------+---------------------------------------------------------
              __e5221452 |         12   -7.40e-17    .1474784  -.2151557    .277543
              __e5221502 |         12   -5.92e-16    4.776847  -3.918895   6.280704
              __e5221551 |         12           0    2.117762  -.7097197    6.72008
              __e5221577 |         12   -3.70e-16    .1070219  -.1261987   .2212315
              __e5221601 |         12           0    .0828239  -.0852631   .1709196
            -------------+---------------------------------------------------------
              __e5221700 |         12    8.33e-17    3.101942  -.9938501    9.84714
              __e5221809 |         12   -2.22e-16    5.192258  -7.117907    4.51183
              __e5221858 |         12   -2.96e-16    6.302823  -4.344419   8.715551
              __e5221908 |         12    3.70e-16    .1168348  -.1506571   .2432659
              __e5222005 |         12           0     .128473  -.1631383   .2764404
            -------------+---------------------------------------------------------
              __e5222054 |         12   -1.11e-16    2.615806  -.8732451   8.303337
              __e5222203 |         12   -5.18e-16    .0821037  -.1153664   .1849888
              __e5222302 |         12   -4.44e-16     .093776  -.1259363   .2382666
            no observations
            r(2000);

            Comment


            • #7
              Bruno:
              have you already checked whether your dataset has missing values?
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment


              • #8
                Yes, Carlo. It does have missing values.

                Comment


                • #9
                  Code:
                  . misstable summ ln_mun_spend_ad_2 ln_r_pib_2_cap i_eleitores_analf_perc perc_pop_bf i_idhm ln_i_pop_total_int
                                                                                 Obs<.
                                                                  +------------------------------
                                 |                                | Unique
                        Variable |     Obs=.     Obs>.     Obs<.  | values        Min         Max
                    -------------+--------------------------------+------------------------------
                    ln_mun_spe~2 |     1,226              65,614  |   >500          0    18.77194
                    ln_r_pib_2~p |        45              66,795  |   >500   5.933629    13.84525
                    i_ele~f_perc |        85              66,755  |   >500    .001022    .4990818
                     perc_pop_bf |        71              66,769  |   >500   .0001094     116.667
                          i_idhm |        79              66,761  |   >500       .339       .8984
                    ln_i_pop_t~t |        44              66,796  |   >500   6.692084    16.30359
                    -----------------------------------------------------------------------------

                  Comment


                  • #10
                    Bruno:
                    that's the reason of your problems, then.
                    Stata adopts listwise deletion with observations having at least one missing value.
                    It ends up with a too small number of observations to allow the community-contributed modules you're interested in to work as expected.
                    Kind regards,
                    Carlo
                    (Stata 19.0)

                    Comment


                    • #11
                      Thank you, Carlo. I had that suspicion. I will identify the missing observations for each variable with a new variable - or set of variables - and use the "if" clause to ask Stata to run xtreg only with non-missing data. If you have any suggestion about how to do that, please feel free to tell. Thanks.

                      Comment


                      • #12
                        I just did the following to filter out missing data when running xtreg. It did not work.

                        Code:
                        egen miss = rowmiss(ln_mun_spend_ad_2 pref_incumb_term_bef party_pres_coal same_party_mayor_gov party_pres ln_r_pib_2_cap ln_r_receitas_totais_2 i_eleitores_analf_perc i_eleitores_ens_sup_perc perc_pop_bf i_idhm i_ideo_na i_fragf i_comp i_pol_pi ln_i_pop_total_int)
                        
                        xtreg ln_mun_spend_ad_2 pref_incumb_term_bef party_pres_coal same_party_mayor_gov party_pres ln_r_pib_2_cap ln_r_receitas_totais_2 i_eleitores_analf_perc i_eleitores_ens_sup_perc perc_pop_bf i_idhm i_ideo_na i_fragf i_comp i_pol_pi ln_i_pop_total_int i.year if wanted==12 & miss==0, fe robust
                        
                        xttest2
                        
                        -------------+---------------------------------------------------------
                          __e5221502 |         12   -2.96e-16    4.768686  -3.932776   6.257788
                          __e5221551 |         12    3.70e-17    2.098931  -.7739754   6.647572
                          __e5221577 |         12    2.22e-16    .1225595  -.1938503   .1558425
                          __e5221601 |         12    3.70e-17     .217493  -.4393697   .4850969
                          __e5221700 |         12   -8.33e-17    3.137535   -1.16737   9.951618
                        -------------+---------------------------------------------------------
                          __e5221809 |         12   -3.70e-16    5.169662  -7.048234   4.369731
                          __e5221858 |         12    2.22e-16    6.331103  -4.420284   8.897104
                          __e5221908 |         12   -5.74e-16    .1118905   -.157901    .215193
                          __e5222005 |         12    1.11e-16     .202801  -.2931289   .3081972
                          __e5222054 |         12   -1.11e-16    2.598316  -.9255286   8.241941
                        -------------+---------------------------------------------------------
                          __e5222203 |         12    1.85e-16    .0975509  -.1590082    .227166
                          __e5222302 |         12    1.67e-16    .1253324  -.1631942   .2973009
                        no observations
                        r(2000);

                        Comment


                        • #13
                          Bruno:
                          and it can't, because Stata considers complete case analysis (and not available case analysis).
                          In other words, with complete case analysis Stata carves out an array of observations that show all observed values.
                          Just to give you an idea, let's consider a fanciful (and technically ridiculous) dataset with 10 ids and 10 variables.
                          1) one id has all the variables plagued with missing values: Stata omits this id and create an -e(sample)- with the remaining 9 ids;
                          2) each id has one missing value in a different variable: Stata throws the message -no observation-.
                          Kind regards,
                          Carlo
                          (Stata 19.0)

                          Comment


                          • #14
                            Thanks Carlo for the clarification. I didn't see the difference between complete and available case analysis right.

                            Comment

                            Working...
                            X