Announcement

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

  • "Not Estimable" results with Margins Command

    Hi,

    I’m looking for help with a STATA margins analysis. My data is a voting and elections database that has one row observation for each election year-state-office code combination, e.g. 2012, California, Presidential Office. Presidential, senatorial, and gubernatorial data goes back to 1980. District level House of Representatives data goes back to 2006.

    My regression code is the following, and produces output without any problems:

    reg deflator_temp win_margin no_incumbent unopposed senate governor presidential non_senate_year non_gubernatorial_year non_presidential_year i.year##i.state_code, r


    However, running the following margins command produces results that are "not estimable:"
    margins year#state_code, atmeans

    When I run the same regression with decade fixed effects instead of year fixed effects I am able to produce margins predicted values. Any thoughts why this is? Any help would be greatly appreciated.

    Anthony



  • #2
    Please show the full regression output. If there are some combinations of year and state_code that do not occur in your estimation sample, the corresponding margins will, of course, be non-estimable. But the regression output will show that with a zero coefficient and (empty) in the standard error column.
    Last edited by Clyde Schechter; 15 Aug 2014, 12:13. Reason: Correct mis-wording

    Comment


    • #3
      The regression output is provided below (sorry it's not complete, there are 17*50 interacted year*state_codes). There are no combinations of year and state_code that are empty, however, margins remains "non-estimable." Thanks!

      . reg deflator_temp c.win_margin unopposed senate president governor non_presidential_y
      > ear i.election_cycle##ib1.state_code, r
      note: 16.election_cycle omitted because of collinearity

      Linear regression Number of obs = 3784
      F(824, 2929) = .
      Prob > F = .
      R-squared = 0.8456
      Root MSE = .05428

      --------------------------------------------------------------------------------------
      | Robust
      deflator_temp | Coef. Std. Err. t P>|t| [95% Conf. Interval]
      ---------------------+----------------------------------------------------------------
      win_margin | -.0555156 .0085691 -6.48 0.000 -.0723176 -.0387136
      unopposed | -.0569567 .0079573 -7.16 0.000 -.0725591 -.0413543
      senate | .0195503 .0021005 9.31 0.000 .0154317 .0236688
      president | .0352048 .0023747 14.82 0.000 .0305485 .0398611
      governor | .0199522 .001586 12.58 0.000 .0168424 .0230621
      non_presidential_y~r | .0201942 .0302443 0.67 0.504 -.039108 .0794963
      |
      election_cycle |
      2 | -.0764414 .0234632 -3.26 0.001 -.1224475 -.0304354
      3 | .0295092 .035298 0.84 0.403 -.0397022 .0987205
      4 | -.0451901 .015661 -2.89 0.004 -.0758978 -.0144825
      5 | .0004333 .031856 0.01 0.989 -.0620292 .0628958
      6 | -.0710912 .0199478 -3.56 0.000 -.1102043 -.0319781
      7 | .0959236 .0270375 3.55 0.000 .042909 .1489381
      8 | -.0845414 .0142676 -5.93 0.000 -.1125169 -.0565658
      9 | .0330271 .0270158 1.22 0.222 -.0199448 .085999
      10 | -.0558282 .0149968 -3.72 0.000 -.0852336 -.0264229
      11 | .0376432 .0315606 1.19 0.233 -.02424 .0995265
      12 | -.0536377 .0144028 -3.72 0.000 -.0818783 -.025397
      13 | .1230411 .0271042 4.54 0.000 .0698959 .1761863
      14 | -.0597307 .0175485 -3.40 0.001 -.0941394 -.0253219
      15 | .1664065 .0318918 5.22 0.000 .103874 .228939
      16 | 0 (omitted)
      17 | .1581001 .0380935 4.15 0.000 .0834073 .232793
      |
      state_code |
      2 | .1481418 .0288122 5.14 0.000 .0916475 .2046361
      3 | .0181749 .026979 0.67 0.501 -.0347249 .0710747
      4 | -.0251672 .0927823 -0.27 0.786 -.2070925 .156758
      5 | .0954332 .0268609 3.55 0.000 .0427651 .1481013
      6 | .1223885 .026956 4.54 0.000 .0695338 .1752432
      7 | .1783591 .026895 6.63 0.000 .1256242 .2310941
      8 | .101548 .027144 3.74 0.000 .0483248 .1547712
      10 | .0416499 .0312265 1.33 0.182 -.0195782 .102878
      11 | -.0448297 .0291401 -1.54 0.124 -.1019668 .0123074
      12 | .020939 .0278674 0.75 0.452 -.0337026 .0755806
      13 | .2416267 .0274532 8.80 0.000 .1877971 .2954562
      14 | .1416483 .0268752 5.27 0.000 .0889521 .1943446
      15 | .1307786 .027054 4.83 0.000 .0777319 .1838254
      16 | .1767611 .0269189 6.57 0.000 .1239793 .2295429
      17 | .1207273 .0269433 4.48 0.000 .0678977 .173557
      18 | .0091924 .0311258 0.30 0.768 -.0518382 .0702231
      19 | -.1495553 .0868697 -1.72 0.085 -.3198872 .0207765
      20 | .2085658 .0300834 6.93 0.000 .149579 .2675526
      21 | .0355193 .0308758 1.15 0.250 -.0250212 .0960598
      22 | .1357834 .0292215 4.65 0.000 .0784866 .1930802
      23 | .1430292 .0279947 5.11 0.000 .0881379 .1979206
      24 | .2411713 .0277881 8.68 0.000 .1866852 .2956574
      25 | .0480209 .0286618 1.68 0.094 -.0081783 .1042201
      26 | .1431912 .0271257 5.28 0.000 .0900038 .1963785
      27 | .1984741 .0278694 7.12 0.000 .1438284 .2531198
      28 | .1363974 .0271425 5.03 0.000 .083177 .1896178
      29 | .0008721 .0285834 0.03 0.976 -.0551734 .0569176
      30 | .1303641 .027295 4.78 0.000 .0768447 .1838835
      31 | .1151984 .0278134 4.14 0.000 .0606626 .1697341
      32 | .0545403 .02933 1.86 0.063 -.0029693 .1120499
      33 | .0487844 .0272261 1.79 0.073 -.0045998 .1021686
      34 | -.0131968 .02749 -0.48 0.631 -.0670985 .0407049
      35 | .213603 .0270789 7.89 0.000 .1605074 .2666985
      36 | .0972953 .0272367 3.57 0.000 .0438904 .1507003
      37 | .0350421 .0448867 0.78 0.435 -.0529705 .1230547
      38 | .1646921 .0269428 6.11 0.000 .1118633 .2175209
      39 | .0663262 .0269102 2.46 0.014 .0135614 .1190909
      40 | .1612359 .0282881 5.70 0.000 .1057693 .2167025
      41 | -.0419528 .0279213 -1.50 0.133 -.0967001 .0127946
      42 | .2333114 .0270014 8.64 0.000 .1803677 .2862552
      43 | -.0016201 .0361242 -0.04 0.964 -.0724514 .0692113
      44 | .0073319 .0282184 0.26 0.795 -.0479979 .0626617
      45 | .2221861 .027157 8.18 0.000 .1689374 .2754349
      46 | .1342967 .0271987 4.94 0.000 .0809661 .1876273
      47 | .0042254 .0339798 0.12 0.901 -.0624012 .0708521
      48 | .1410684 .0273376 5.16 0.000 .0874655 .1946713
      49 | .0762407 .0277358 2.75 0.006 .0218571 .1306243
      50 | .2175442 .0269673 8.07 0.000 .1646673 .2704211
      51 | .1037342 .027713 3.74 0.000 .0493952 .1580732
      |
      election_cycle#|
      state_code |
      2 2 | .0946897 .0345743 2.74 0.006 .0268972 .1624821
      2 3 | -.0376782 .0331004 -1.14 0.255 -.1025806 .0272243
      2 4 | .1178034 .0947125 1.24 0.214 -.0679064 .3035132

      Comment


      • #4
        Anthony -- welcome to Statalist. Thanks for posting your output. It would be a great help to legibility if you were to include your Stata code and output between CODE delimiters -- that way it gets nicely formatted and easier to read (and copy/paste). It's easy to do. Use the advanced editor functions which are accessible by hitting the underlined-A on RHS above where you enter text. On the strip that appears you'll see a "#" button. There are also ways to "tag" URLs to ensure they become links. Etc. thanks.
        Last edited by Stephen Jenkins; 20 Aug 2014, 09:16.

        Comment


        • #5
          So, the first thing I notice from your regression output is that your overall F-statistic is missing. When you are doing regression with robust standard errors, this can arise when you have a dummy variable that only takes the 1-value in a single observation (within the estimation sample). I'm not 100% sure that this is the source of the non-estimable results in -margins-, but I suspect it is. The particular -margins- that are not estimable might give you a hint as to which variable(s) are singleton dummies. Or you can just -tab- them and look directly for that phenomenon.

          This would also explain why when you aggregate up to decades instead of years the problem disappears, as those singletons get merged with other years.

          Also, I notice that the indicator for election cycle 16 has been dropped due to collinearity, which may mean that it is not instantiated in the estimation sample.

          Both of these suggest that you review the distributions of all your indicator variables in the estimation sample.
          Last edited by Clyde Schechter; 20 Aug 2014, 09:24.

          Comment


          • #6
            Hi Stephen, Thanks for the information -- I searched how to include output in a better format but couldn't find anything. Here's the output:

            Code:
             reg deflator_temp c.win_margin unopposed senate president governor non_presidential_year i.election_cycle##ib1.state_code, r
            Code:
             Output
            note: 16.election_cycle omitted because of collinearity
            
            Linear regression                                      Number of obs =    3784
                                                                   F(824,  2929) =       .
                                                                   Prob > F      =       .
                                                                   R-squared     =  0.8456
                                                                   Root MSE      =  .05428
            
            --------------------------------------------------------------------------------------
                                 |               Robust
                   deflator_temp |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            ---------------------+----------------------------------------------------------------
                      win_margin |  -.0555156   .0085691    -6.48   0.000    -.0723176   -.0387136
                       unopposed |  -.0569567   .0079573    -7.16   0.000    -.0725591   -.0413543
                          senate |   .0195503   .0021005     9.31   0.000     .0154317    .0236688
                       president |   .0352048   .0023747    14.82   0.000     .0305485    .0398611
                        governor |   .0199522    .001586    12.58   0.000     .0168424    .0230621
            non_presidential_y~r |   .0201942   .0302443     0.67   0.504     -.039108    .0794963
                                 |
                  election_cycle |
                              2  |  -.0764414   .0234632    -3.26   0.001    -.1224475   -.0304354
                              3  |   .0295092    .035298     0.84   0.403    -.0397022    .0987205
                              4  |  -.0451901    .015661    -2.89   0.004    -.0758978   -.0144825
                              5  |   .0004333    .031856     0.01   0.989    -.0620292    .0628958
                              6  |  -.0710912   .0199478    -3.56   0.000    -.1102043   -.0319781
                              7  |   .0959236   .0270375     3.55   0.000      .042909    .1489381
                              8  |  -.0845414   .0142676    -5.93   0.000    -.1125169   -.0565658
                              9  |   .0330271   .0270158     1.22   0.222    -.0199448     .085999
                             10  |  -.0558282   .0149968    -3.72   0.000    -.0852336   -.0264229
                             11  |   .0376432   .0315606     1.19   0.233      -.02424    .0995265
                             12  |  -.0536377   .0144028    -3.72   0.000    -.0818783    -.025397
                             13  |   .1230411   .0271042     4.54   0.000     .0698959    .1761863
                             14  |  -.0597307   .0175485    -3.40   0.001    -.0941394   -.0253219
                             15  |   .1664065   .0318918     5.22   0.000      .103874     .228939
                             16  |          0  (omitted)
                             17  |   .1581001   .0380935     4.15   0.000     .0834073     .232793
              
            
            ​
            Last edited by Anthony Cozart; 20 Aug 2014, 09:27.

            Comment


            • #7
              Code:
                                 |
                        state_code |
                                2  |   .1481418   .0288122     5.14   0.000     .0916475    .2046361
                                3  |   .0181749    .026979     0.67   0.501    -.0347249    .0710747
                                4  |  -.0251672   .0927823    -0.27   0.786    -.2070925     .156758
                                5  |   .0954332   .0268609     3.55   0.000     .0427651    .1481013
                                6  |   .1223885    .026956     4.54   0.000     .0695338    .1752432
                                7  |   .1783591    .026895     6.63   0.000     .1256242    .2310941
                                8  |    .101548    .027144     3.74   0.000     .0483248    .1547712
                               10  |   .0416499   .0312265     1.33   0.182    -.0195782     .102878
                               11  |  -.0448297   .0291401    -1.54   0.124    -.1019668    .0123074
                               12  |    .020939   .0278674     0.75   0.452    -.0337026    .0755806
                               13  |   .2416267   .0274532     8.80   0.000     .1877971    .2954562
                               14  |   .1416483   .0268752     5.27   0.000     .0889521    .1943446
                               15  |   .1307786    .027054     4.83   0.000     .0777319    .1838254
                               16  |   .1767611   .0269189     6.57   0.000     .1239793    .2295429
                               17  |   .1207273   .0269433     4.48   0.000     .0678977     .173557
                               18  |   .0091924   .0311258     0.30   0.768    -.0518382    .0702231
                               19  |  -.1495553   .0868697    -1.72   0.085    -.3198872    .0207765
                               20  |   .2085658   .0300834     6.93   0.000      .149579    .2675526
                               21  |   .0355193   .0308758     1.15   0.250    -.0250212    .0960598
                               22  |   .1357834   .0292215     4.65   0.000     .0784866    .1930802
                               23  |   .1430292   .0279947     5.11   0.000     .0881379    .1979206
                               24  |   .2411713   .0277881     8.68   0.000     .1866852    .2956574
                               25  |   .0480209   .0286618     1.68   0.094    -.0081783    .1042201
                               26  |   .1431912   .0271257     5.28   0.000     .0900038    .1963785
                               27  |   .1984741   .0278694     7.12   0.000     .1438284    .2531198
                               28  |   .1363974   .0271425     5.03   0.000      .083177    .1896178
                               29  |   .0008721   .0285834     0.03   0.976    -.0551734    .0569176
                               30  |   .1303641    .027295     4.78   0.000     .0768447    .1838835
                               31  |   .1151984   .0278134     4.14   0.000     .0606626    .1697341
                               32  |   .0545403     .02933     1.86   0.063    -.0029693    .1120499
                               33  |   .0487844   .0272261     1.79   0.073    -.0045998    .1021686
                               34  |  -.0131968     .02749    -0.48   0.631    -.0670985    .0407049
                               35  |    .213603   .0270789     7.89   0.000     .1605074    .2666985
                               36  |   .0972953   .0272367     3.57   0.000     .0438904    .1507003
                               37  |   .0350421   .0448867     0.78   0.435    -.0529705    .1230547
                               38  |   .1646921   .0269428     6.11   0.000     .1118633    .2175209
                               39  |   .0663262   .0269102     2.46   0.014     .0135614    .1190909
                               40  |   .1612359   .0282881     5.70   0.000     .1057693    .2167025
                               41  |  -.0419528   .0279213    -1.50   0.133    -.0967001    .0127946
                               42  |   .2333114   .0270014     8.64   0.000     .1803677    .2862552
                               43  |  -.0016201   .0361242    -0.04   0.964    -.0724514    .0692113
                               44  |   .0073319   .0282184     0.26   0.795    -.0479979    .0626617
                               45  |   .2221861    .027157     8.18   0.000     .1689374    .2754349
                               46  |   .1342967   .0271987     4.94   0.000     .0809661    .1876273
                               47  |   .0042254   .0339798     0.12   0.901    -.0624012    .0708521
                               48  |   .1410684   .0273376     5.16   0.000     .0874655    .1946713
                               49  |   .0762407   .0277358     2.75   0.006     .0218571    .1306243
                               50  |   .2175442   .0269673     8.07   0.000     .1646673    .2704211
                               51  |   .1037342    .027713     3.74   0.000     .0493952    .1580732
                                   |
                    election_cycle#|
                        state_code |
                             2  2  |   .0946897   .0345743     2.74   0.006     .0268972    .1624821
                             2  3  |  -.0376782   .0331004    -1.14   0.255    -.1025806    .0272243
                             2  4  |   .1178034   .0947125     1.24   0.214    -.0679064    .3035132
                             2  5  |   .0001964   .0329798     0.01   0.995    -.0644695    .0648623
                             2  6  |  -.0622423    .033009    -1.89   0.059    -.1269654    .0024808
                             2  7  |  -.0826772   .0331769    -2.49   0.013    -.1477296   -.0176248
                             2  8  |  -.0387451   .0334703    -1.16   0.247    -.1043728    .0268826
                             2 10  |  -.0846556   .0404029    -2.10   0.036    -.1638766   -.0054346
                             2 11  |  -.0664823   .0420196    -1.58   0.114    -.1488733    .0159086
                             2 12  |   .0708298   .0339551     2.09   0.037     .0042514    .1374081
                             2 13  |  -.1252286   .0338254    -3.70   0.000    -.1915527   -.0589046
                             2 14  |  -.0632857   .0333434    -1.90   0.058    -.1286646    .0020933
                             2 15  |  -.0451108   .0333605    -1.35   0.176    -.1105233    .0203016
                             2 16  |  -.0636097   .0329818    -1.93   0.054    -.1282796    .0010601
                             2 17  |  -.0628908   .0333612    -1.89   0.060    -.1283045    .0025229
                             2 18  |  -.1125319   .0365025    -3.08   0.002    -.1841049   -.0409588
                             2 19  |  -.0474921   .0889254    -0.53   0.593    -.2218547    .1268705
                             2 20  |  -.0251833   .0356155    -0.71   0.480    -.0950174    .0446507
                             2 21  |  -.0436427   .0363324    -1.20   0.230    -.1148824    .0275969
                             2 22  |  -.0351829   .0360393    -0.98   0.329    -.1058477     .035482
                             2 23  |  -.0606683   .0343819    -1.76   0.078    -.1280834    .0067468
                             2 24  |   .0019419   .0380669     0.05   0.959    -.0726987    .0765825
                             2 25  |  -.0526868   .0344601    -1.53   0.126    -.1202552    .0148816
                             2 26  |  -.0941645   .0337496    -2.79   0.005    -.1603399    -.027989
                             2 27  |  -.0166118   .0339096    -0.49   0.624    -.0831008    .0498773
                             2 28  |  -.0353319   .0335663    -1.05   0.293    -.1011477    .0304839
                             2 29  |  -.0006502   .0344955    -0.02   0.985    -.0682881    .0669876
                             2 30  |  -.1077937   .0332963    -3.24   0.001    -.1730801   -.0425073
                             2 31  |  -.0810932   .0339692    -2.39   0.017    -.1476991   -.0144872
                             2 32  |   .0000618   .0350413     0.00   0.999    -.0686463    .0687698
                             2 33  |  -.0181821   .0341882    -0.53   0.595    -.0852174    .0488533
                             2 34  |  -.0567637   .0334536    -1.70   0.090    -.1223586    .0088312
                             2 35  |  -.0274652   .0344217    -0.80   0.425    -.0949584     .040028
                             2 36  |  -.0396265   .0332751    -1.19   0.234    -.1048714    .0256184
                             2 37  |  -.0317712   .0487586    -0.65   0.515    -.1273758    .0638335
                             2 38  |   .0030845   .0330984     0.09   0.926    -.0618139    .0679829
                             2 39  |  -.0319238   .0331841    -0.96   0.336    -.0969903    .0331428
                             2 40  |  -.0438472   .0344472    -1.27   0.203    -.1113904    .0236961
                             2 41  |  -.0352609   .0339065    -1.04   0.298    -.1017439    .0312221
                             2 42  |  -.0373079   .0331426    -1.13   0.260    -.1022931    .0276773
                             2 43  |  -.0109795   .0411151    -0.27   0.789     -.091597     .069638
                             2 44  |  -.0902371   .0344218    -2.62   0.009    -.1577305   -.0227437
                             2 45  |  -.0834703   .0409663    -2.04   0.042     -.163796   -.0031446
                             2 46  |  -.0601291   .0346485    -1.74   0.083    -.1280669    .0078087
                             2 47  |  -.0384986   .0390175    -0.99   0.324    -.1150032    .0380059
                             2 48  |  -.0648269    .034826    -1.86   0.063    -.1331129    .0034591
                             2 49  |  -.0494034   .0340039    -1.45   0.146    -.1160775    .0172706
                             2 50  |  -.1427151    .033933    -4.21   0.000      -.20925   -.0761802
                             2 51  |   .0049931   .0337516     0.15   0.882    -.0611863    .0711724
                             3  2  |   -.004645   .0371322    -0.13   0.900    -.0774528    .0681628
                             3  3  |   -.025456   .0361614    -0.70   0.482    -.0963603    .0454483
                             3  4  |   .0247156   .1111357     0.22   0.824    -.1931965    .2426276
                             3  5  |  -.0113801   .0354138    -0.32   0.748    -.0808185    .0580582
                             3  6  |  -.0228555   .0357361    -0.64   0.523     -.092926     .047215
                             3  7  |  -.0178315   .0354875    -0.50   0.615    -.0874145    .0517515
                             3  8  |    -.01127   .0357809    -0.31   0.753    -.0814283    .0588884
                             3 10  |  -.0943287   .0893224    -1.06   0.291    -.2694697    .0808123
                             3 11  |  -.0133359   .0395449    -0.34   0.736    -.0908745    .0642028
                             3 12  |  -.0439663   .0392908    -1.12   0.263    -.1210066     .033074
                             3 13  |  -.0846799   .0357818    -2.37   0.018    -.1548401   -.0145198
                             3 14  |  -.0186645   .0353897    -0.53   0.598    -.0880557    .0507267
                             3 15  |  -.0393464   .0356191    -1.10   0.269    -.1091874    .0304947
                             3 16  |  -.0208337   .0354022    -0.59   0.556    -.0902493     .048582
                             3 17  |  -.0070703   .0355138    -0.20   0.842    -.0767047    .0625642
                             3 18  |   .0038517   .0404347     0.10   0.924    -.0754316     .083135
                             3 19  |   .0486123   .1317661     0.37   0.712    -.2097513    .3069758
                             3 20  |  -.0156688    .038536    -0.41   0.684    -.0912292    .0598915
                             3 21  |   .0001909   .0396415     0.00   0.996    -.0775372     .077919
                             3 22  |  -.0293621    .037833    -0.78   0.438    -.1035441      .04482
                             3 23  |   -.045258   .0370834    -1.22   0.222    -.1179701    .0274541
                             3 24  |  -.0296822   .0364942    -0.81   0.416    -.1012391    .0418747
                             3 25  |   .0059474    .038002     0.16   0.876    -.0685659    .0804606
                             3 26  |  -.0358105   .0355452    -1.01   0.314    -.1055067    .0338857
                             3 27  |  -.0104035    .036282    -0.29   0.774    -.0815443    .0607373
                             3 28  |  -.0313022   .0367305    -0.85   0.394    -.1033224     .040718
                             3 29  |  -.0408808   .0366134    -1.12   0.264    -.1126714    .0309099
                             3 30  |  -.0604482   .0356301    -1.70   0.090    -.1303108    .0094145
                             3 31  |   .0007095    .036423     0.02   0.984    -.0707078    .0721269
                             3 32  |   .0105575   .0374532     0.28   0.778    -.0628798    .0839948
                             3 33  |   .0099164   .0362491     0.27   0.784    -.0611598    .0809927
                             3 34  |   .0288304   .0360596     0.80   0.424    -.0418744    .0995352
                             3 35  |  -.0251236   .0405687    -0.62   0.536    -.1046697    .0544226
                             3 36  |   .0061615   .0356203     0.17   0.863    -.0636819    .0760048
                             3 37  |   .0167065   .0523354     0.32   0.750    -.0859113    .1193244
                             3 38  |   .0045187   .0358561     0.13   0.900     -.065787    .0748245
                             3 39  |   .0004781   .0355836     0.01   0.989    -.0692934    .0702495
                             3 40  |  -.0537903    .036722    -1.46   0.143    -.1257938    .0182133
                             3 41  |  -.0134118   .0364699    -0.37   0.713     -.084921    .0580975
                             3 42  |  -.0531906   .0361731    -1.47   0.142    -.1241179    .0177367
                             3 43  |  -.0104976   .0511293    -0.21   0.837    -.1107507    .0897555
                             3 44  |   .0093977   .0393389     0.24   0.811    -.0677371    .0865325
                             3 45  |  -.0647886   .0357183    -1.81   0.070    -.1348241    .0052469
                             3 46  |    .006524    .036272     0.18   0.857    -.0645973    .0776452
                             3 47  |   .0185638   .0436984     0.42   0.671    -.0671189    .1042466
                             3 48  |  -.0085134   .0358544    -0.24   0.812    -.0788157     .061789
                             3 49  |   -.023548   .0365172    -0.64   0.519    -.0951499     .048054
                             3 50  |  -.0622166   .0356019    -1.75   0.081    -.1320238    .0075907
                             3 51  |   .0018311   .0370646     0.05   0.961    -.0708442    .0745063
              ....
              
                             _cons |   .4288561   .0269104    15.94   0.000     .3760909    .4816213
              --------------------------------------------------------------------------------------

              Comment


              • #8
                Thanks for this. I think Clyde is providing you with lots of useful comments to follow up for now. (Clearly, he has better eyes than me too!)

                Comment


                • #9
                  Clyde,

                  Thanks for your insightful comments. I know I have "singleton dummies" that are election and state_code combinations (i.e. state_code==10, year==2006). I need to get more row observations to address this.

                  Your point about the collinearity brings up a broader issue I'm facing, that is even when altering the sample window, I have one year drop. For example, dropping data for 2010 and 2010, the indicator variable for the year before the final year in the sample drops. The code below provides an example. Any idea why this is the case?

                  Code:
                  keep if year<=2008
                  (500 observations deleted)
                  
                  . reg deflator_temp c.win_margin unopposed senate president governor non_presidential_y
                  > ear i.election_cycle##ib1.state_code, r
                  note: 14.election_cycle omitted because of collinearity
                  
                  Linear regression                                      Number of obs =    2758
                                                                         F(726,  2003) =       .
                                                                         Prob > F      =       .
                                                                         R-squared     =  0.8910
                                                                         Root MSE      =  .04625
                  
                  --------------------------------------------------------------------------------------
                                       |               Robust
                         deflator_temp |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                  ---------------------+----------------------------------------------------------------
                            win_margin |  -.0678246   .0096701    -7.01   0.000     -.086789   -.0488601
                             unopposed |  -.0570672   .0091262    -6.25   0.000     -.074965   -.0391695
                                senate |   .0275919   .0025205    10.95   0.000     .0226489    .0325349
                             president |   .0426071   .0025987    16.40   0.000     .0375106    .0477036
                              governor |   .0263274   .0017781    14.81   0.000     .0228403    .0298145
                  non_presidential_y~r |  -.0285831    .028788    -0.99   0.321    -.0850408    .0278745
                                       |
                        election_cycle |
                                    2  |  -.0245272   .0222417    -1.10   0.270    -.0681464    .0190921
                                    3  |   .0314312   .0333937     0.94   0.347    -.0340587    .0969211
                                    4  |   .0042712   .0152558     0.28   0.780    -.0256478    .0341901
                                    5  |   .0029477   .0295561     0.10   0.921    -.0550163    .0609117
                                    6  |  -.0210511   .0187926    -1.12   0.263    -.0579061    .0158039
                                    7  |   .0972587   .0256099     3.80   0.000      .047034    .1474835
                                    8  |  -.0340818   .0138266    -2.46   0.014    -.0611979   -.0069658
                                    9  |   .0333146   .0257187     1.30   0.195    -.0171236    .0837529
                                   10  |  -.0052583   .0143776    -0.37   0.715     -.033455    .0229383
                                   11  |   .0398936   .0291428     1.37   0.171    -.0172597    .0970469
                                   12  |  -.0039894   .0140002    -0.28   0.776    -.0314458    .0234671
                                   13  |   .1253206   .0253932     4.94   0.000     .0755208    .1751205
                                   14  |          0  (omitted)
                                   15  |   .1750798   .0314348     5.57   0.000     .1134314    .2367282
                                       |
                            state_code |
                                    2  |   .1512377   .0290475     5.21   0.000     .0942712    .2082041
                                    3  |    .019258   .0256495     0.75   0.453    -.0310444    .0695604
                                    4  |  -.0246665      .0931    -0.26   0.791    -.2072494    .1579164
                                    5  |   .0965853   .0252613     3.82   0.000     .0470441    .1461265
                                    6  |    .123185   .0256221     4.81   0.000     .0729361    .1734338
                                    7  |   .1789968   .0253881     7.05   0.000      .129207    .2287865
                                    8  |   .1045869   .0257877     4.06   0.000     .0540134    .1551603
                                   10  |   .0421952   .0291213     1.45   0.148    -.0149161    .0993064
                                   11  |  -.0443076   .0268667    -1.65   0.099    -.0969972    .0083821
                                   12  |   .0247217   .0273177     0.90   0.366    -.0288523    .0782957
                                   13  |   .2432748   .0256332     9.49   0.000     .1930042    .2935454
                                   14  |   .1422056   .0252311     5.64   0.000     .0927237    .1916876
                                   15  |   .1314209   .0256497     5.12   0.000     .0811181    .1817237
                                   16  |   .1772896   .0254458     6.97   0.000     .1273867    .2271926
                                   17  |   .1226291   .0253383     4.84   0.000     .0729369    .1723212
                                   18  |   .0102487   .0289944     0.35   0.724    -.0466137    .0671111
                                   19  |  -.1447193   .0854632    -1.69   0.091    -.3123254    .0228868
                                   20  |   .2113056   .0310137     6.81   0.000     .1504831    .2721281
                                   21  |   .0367508   .0296842     1.24   0.216    -.0214643     .094966
                                   22  |   .1370656   .0266582     5.14   0.000     .0847849    .1893463
                                   23  |   .1445584   .0257763     5.61   0.000     .0940073    .1951096
                                   24  |    .242557   .0255962     9.48   0.000      .192359    .2927549
                                   25  |    .049405   .0262033     1.89   0.060    -.0019836    .1007935
                                   26  |   .1430884   .0257922     5.55   0.000     .0925061    .1936708
                                   27  |   .2002185   .0259367     7.72   0.000     .1493528    .2510842
                                   28  |   .1408696   .0258532     5.45   0.000     .0901677    .1915715
                                   29  |   .0045753   .0283496     0.16   0.872    -.0510226    .0601731
                                   30  |     .13136   .0257507     5.10   0.000      .080859    .1818609
                                   31  |   .1171421   .0257143     4.56   0.000     .0667124    .1675717
                                   32  |   .0568541   .0271058     2.10   0.036     .0036956    .1100126
                                   33  |   .0486137   .0252935     1.92   0.055    -.0009906    .0982179
                                   34  |  -.0129733   .0261753    -0.50   0.620    -.0643069    .0383603
                                   35  |   .2160601   .0255343     8.46   0.000     .1659835    .2661367
                                   36  |   .0990731   .0254215     3.90   0.000     .0492179    .1489284
                                   37  |   .0361997    .043486     0.83   0.405    -.0490828    .1214823
                                   38  |   .1652861   .0253106     6.53   0.000     .1156483    .2149239
                                   39  |   .0663855   .0255237     2.60   0.009     .0163297    .1164413
                                   40  |    .164046   .0269052     6.10   0.000      .111281     .216811
                                   41  |  -.0405581   .0266485    -1.52   0.128    -.0928198    .0117037
                                   42  |    .235104   .0253762     9.26   0.000     .1853374    .2848706
                                   43  |  -.0004655   .0333629    -0.01   0.989    -.0658951    .0649641
                                   44  |   .0093454   .0260425     0.36   0.720    -.0417278    .0604186
                                   45  |   .2252719   .0257236     8.76   0.000     .1748242    .2757197
                                   46  |   .1363469   .0261915     5.21   0.000     .0849815    .1877124
                                   47  |   .0063245   .0315058     0.20   0.841    -.0554631    .0681121
                                   48  |    .141479   .0255363     5.54   0.000     .0913986    .1915595
                                   49  |   .0771455   .0260416     2.96   0.003     .0260741     .128217
                                   50  |   .2174806   .0252818     8.60   0.000     .1678994    .2670619
                                   51  |    .109264   .0271673     4.02   0.000     .0559848    .1625432
                                       |
                        election_cycle#|
                            state_code |
                                 2  2  |   .0932292   .0339544     2.75   0.006     .0266395    .1598188
                                 2  3  |  -.0398712   .0313648    -1.27   0.204    -.1013822    .0216398
                                 2  4  |   .1164415   .0947367     1.23   0.219    -.0693513    .3022344
                                 2  5  |  -.0037577   .0310188    -0.12   0.904    -.0645901    .0570748
                                 2  6  |  -.0624186    .031099    -2.01   0.045    -.1234084   -.0014289

                  Comment


                  • #10
                    So it sounds like you have some sparse data in the estimation sample, with empty or singleton cells in your cross-tab of election cycle with state. In situations like that it is very easy for an indicator variable to end up collinear with an interaction term (and, hence, one of those gets dropped). I think your options are either to find more data, or to aggregate up to larger time periods or groups of similar states (whatever that means), or restrict your analysis to time periods or a subset of the states where the data are rich. Another possibility is that your estimation sample is sparse because of missing values for the other variables in your model. Removing some of those from the model might improve the situation, if that doesn't do violence to the underlying theory.

                    Comment


                    • #11
                      Clyde,

                      Thanks again. Could you elaborate why it might be easy for an indicator variable to end up collinear with an interaction term in data with empty or singleton cells?

                      Anthony

                      Comment


                      • #12
                        Well, perhaps an example where you can play with it yourself and see what's going on. This example involves sparse data, with some zeroes, and one cell with only two observations:

                        Code:
                         . sysuse auto, clear
                        (1978 Automobile Data)
                          . tab rep78 foreign
                              Repair |
                            Record |       Car type
                              1978 |  Domestic    Foreign |     Total
                        -----------+----------------------+----------
                                 1 |         2          0 |         2
                                 2 |         8          0 |         8
                                 3 |        27          3 |        30
                                 4 |         9          9 |        18
                                 5 |         2          9 |        11
                        -----------+----------------------+----------
                             Total |        48         21 |        69
                          
                        . regress price i.rep78##i.foreign
                        note: 1b.rep78#1.foreign identifies no observations in the sample
                        note: 2.rep78#1.foreign identifies no observations in the sample
                        note: 5.rep78#1.foreign omitted because of collinearity
                                Source |       SS       df       MS              Number of obs =      69
                        -------------+------------------------------           F(  7,    61) =    0.39
                               Model |    24684607     7  3526372.43           Prob > F      =  0.9049
                            Residual |   552112352    61  9051022.16           R-squared     =  0.0428
                        -------------+------------------------------           Adj R-squared = -0.0670
                               Total |   576796959    68  8482308.22           Root MSE      =  3008.5
                          -------------------------------------------------------------------------------
                                price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                        --------------+----------------------------------------------------------------
                                rep78 |
                                   2  |   1403.125   2378.422     0.59   0.557    -3352.823    6159.073
                                   3  |   2042.574   2204.707     0.93   0.358    -2366.011    6451.159
                                   4  |   1317.056   2351.846     0.56   0.578    -3385.751    6019.863
                                   5  |       -360   3008.492    -0.12   0.905    -6375.851    5655.851
                                      |
                              foreign |
                             Foreign  |   2088.167   2351.846     0.89   0.378     -2614.64    6790.974
                                      |
                        rep78#foreign |
                           1#Foreign  |          0  (empty)
                           2#Foreign  |          0  (empty)
                           3#Foreign  |  -3866.574   2980.505    -1.30   0.199    -9826.462    2093.314
                           4#Foreign  |  -1708.278   2746.365    -0.62   0.536    -7199.973    3783.418
                           5#Foreign  |          0  (omitted)
                                      |
                                _cons |     4564.5   2127.325     2.15   0.036      310.651    8818.349
                        -------------------------------------------------------------------------------
                        So, the dropping of the levels 1 and 2 interactions between rep78 and foreign is no surprise: there are no such observations. But notice that 5.rep78#1.foreign ends up being omitted because of collinearity. To see why, let's regress 5.rep78#1.foreign on the other predictors. We can't actually specify our dependent variable as 5.rep78#1.foreign, so first we'll have to make it a "real" variable:

                        Code:
                          . gen dropped = 5.rep78#1.foreign
                        (5 missing values generated)
                          . regress dropped i.rep78 i.foreign i(2/4).rep78#i.foreign
                        note: 2b.rep78#1.foreign identifies no observations in the sample
                                Source |       SS       df       MS              Number of obs =      69
                        -------------+------------------------------           F(  5,    63) =       .
                               Model |  7.82608696     5  1.56521739           Prob > F      =       .
                            Residual |           0    63           0           R-squared     =  1.0000
                        -------------+------------------------------           Adj R-squared =  1.0000
                               Total |  7.82608696    68  .115089514           Root MSE      =       0
                          -------------------------------------------------------------------------------
                              dropped |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                        --------------+----------------------------------------------------------------
                                rep78 |
                                   3  |  -6.43e-17          .        .       .            .           .
                                   4  |  -2.85e-16          .        .       .            .           .
                                      |
                              foreign |
                             Foreign  |          1          .        .       .            .           .
                                      |
                        rep78#foreign |
                           2#Foreign  |          0  (empty)
                           3#Foreign  |         -1          .        .       .            .           .
                           4#Foreign  |         -1          .        .       .            .           .
                                      |
                                _cons |   2.78e-17          .        .       .            .           .
                        -------------------------------------------------------------------------------
                        This regression tells us that 5.rep78#1.foreign is equal to 1.foreign - (3.rep78#1.foreign + 4.rep78#1.foreign)*, which is an algebraic way of saying that you are in repair category 5 and foreign if and only if you are foreign, but in neither repair category 3 nor repair category 4. This is a coincidental relationship in the data that arises from the absence of repair categories 1 and 2 among the foreign observations and the small number of domestic observations in repair category 5. A richer data set could, of course, contain the same relationship, but it is far less likely to happen (and, if it does, it is likely to be something systematic that should be taken account of in study design). These coincidental relationships can crop up easily when there are lots of small cells.

                        Hope this helps.

                        * the other coefficients are just zeroes with a small amount of numerical error.

                        Comment


                        • #13
                          Going back to a point you made early in our exchange yesterday, I'm surprised that the the indicator for election cycle 16 is dropped because of collinearity. What I've done to explore the issue is to look at just one state, and the election cycles 2010 and 2012 (cycles 16, 17). The same problem arises. There are 55 observations for both years, so it's not a problem of an election cycle not being instantiated. "Non_senate_year" is dropped because there's no variation. "Non_gubernatorial_year" is dropped because of collinearity as a result of sparse data. Do you have any idea why 17.election_year is dropped?


                          Thanks again for your help, I really appreciate it.

                          Code:
                          .
                          keep if state_code==5
                          (3570 observations deleted)
                          
                          keep if year>=2010
                          (144 observations deleted)
                          
                          
                          reg deflator_temp c.win_margin unopposed senate president governor non_presidential_year non_senate_year non_gubernatorial_year i.election_cycle, r
                          note: non_senate_year omitted because of collinearity
                          note: non_gubernatorial_year omitted because of collinearity
                          note: 17.election_cycle omitted because of collinearity
                          
                          Linear regression                                      Number of obs =     110
                                                                                 F(  4,   103) =       .
                                                                                 Prob > F      =       .
                                                                                 R-squared     =  0.2918
                                                                                 Root MSE      =  .10958
                          
                          --------------------------------------------------------------------------------------
                                               |               Robust
                                 deflator_temp |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                          ---------------------+----------------------------------------------------------------
                                    win_margin |   .0808634   .0596059     1.36   0.178    -.0373508    .1990777
                                     unopposed |  -.1483611   .0419767    -3.53   0.001    -.2316119   -.0651103
                                        senate |   .0091408   .0224109     0.41   0.684     -.035306    .0535875
                                     president |    .006913   .0188749     0.37   0.715    -.0305209    .0443469
                                      governor |   .0342378   .0177401     1.93   0.056    -.0009454     .069421
                          non_presidential_y~r |  -.1306358   .0214957    -6.08   0.000    -.1732674   -.0880041
                               non_senate_year |          0  (omitted)
                          non_gubernatorial_~r |          0  (omitted)
                             17.election_cycle |          0  (omitted)
                                         _cons |   .5264039   .0267064    19.71   0.000     .4734381    .5793698
                          --------------------------------------------------------------------------------------
                          
                          . gen dropped=non_gubernatorial_year
                          
                          . reg dropped c.win_margin unopposed senate president governor non_presidential_year non_senate_year i.election_cycle
                          note: non_senate_year omitted because of collinearity
                          note: 17.election_cycle omitted because of collinearity
                          
                                Source |       SS       df       MS              Number of obs =     110
                          -------------+------------------------------           F(  6,   103) =       .
                                 Model |        27.5     6  4.58333333           Prob > F      =       .
                              Residual |           0   103           0           R-squared     =  1.0000
                          -------------+------------------------------           Adj R-squared =  1.0000
                                 Total |        27.5   109  .252293578           Root MSE      =       0
                          
                          --------------------------------------------------------------------------------------
                                       dropped |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                          ---------------------+----------------------------------------------------------------
                                    win_margin |   2.46e-17          .        .       .            .           .
                                     unopposed |   8.91e-17          .        .       .            .           .
                                        senate |   4.31e-18          .        .       .            .           .
                                     president |  -5.58e-17          .        .       .            .           .
                                      governor |          0  (omitted)
                          non_presidential_y~r |         -1          .        .       .            .           .
                               non_senate_year |          0  (omitted)
                             17.election_cycle |          0  (omitted)
                                         _cons |          1          .        .       .            .           .
                          --------------------------------------------------------------------------------------

                          Comment


                          • #14
                            Clearly it's a problem with my data structure. The problem of a election_cycle dropping does not arise if I keep only two non-consecutive election cycles, for example 2006 and 2010, shown below:

                            Code:
                            . keep if state_code==5
                            (3570 observations deleted)
                            
                            . keep if year==2006| year==2010
                            (144 observations deleted)
                            
                            . reg deflator_temp c.win_margin unopposed senate president governor non_presidential_year i.election_cycle, r
                            note: president omitted because of collinearity
                            note: non_presidential_year omitted because of collinearity
                            
                            Linear regression                                      Number of obs =     110
                                                                                   F(  5,   104) =   34.69
                                                                                   Prob > F      =  0.0000
                                                                                   R-squared     =  0.2558
                                                                                   Root MSE      =  .07648
                            
                            --------------------------------------------------------------------------------------
                                                 |               Robust
                                   deflator_temp |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                            ---------------------+----------------------------------------------------------------
                                      win_margin |  -.0337432   .0533033    -0.63   0.528    -.1394456    .0719592
                                       unopposed |  -.0887607   .0338874    -2.62   0.010    -.1559606   -.0215607
                                          senate |   .0124272   .0137183     0.91   0.367    -.0147766    .0396311
                                       president |          0  (omitted)
                                        governor |   .0169325   .0145102     1.17   0.246    -.0118417    .0457068
                            non_presidential_y~r |          0  (omitted)
                               16.election_cycle |   .0476196   .0146911     3.24   0.002     .0184865    .0767527
                                           _cons |   .3855862   .0211857    18.20   0.000     .3435742    .4275982
                            --------------------------------------------------------------------------------------
                            * There's no variation in president and non_presidential_year variables.

                            Comment


                            • #15
                              When a variable is dropped due to collinearity, and you don't know why, you can just regress that variable against all the other predictor variables in the offending regression. When the variable is a level of a factor variable, you have to first create a "real" variable that is equal to it, because factor variable notation is not permitted in the dependent variable. So I would do the following immediately after the offending regression:

                              Code:
                              gen ec_17 = 17.election_cycle
                              regress ec_17 c.win_margin unopposed senate president governor non_presidential_year non_senate_year if e(sample)
                              The output of that will have many zero coefficients (or extremely close to zero). The variables whose coefficients are non-zero are the ones which are involved in a collinearity relationship with 17.election_cycle, and they also give you the actual linear relationship among them. You may find out that in state 5 in the years after 2010, the 17th election cycle was the only one in which there was an unopposed election involving a governor, or something like that. Those kinds of coincidental relationships crop up frequently in sparse data with many variables.

                              Comment

                              Working...
                              X