Announcement

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

  • No observations in xtreg

    Hi statlist,

    I have a panel as follows:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double(cem_weights idfirm) int Year float log_tot_sales byte recalled_dummy_byfirm float inflow_ratio double nprod
                   0 1 2004         . .          .   .
                   0 1 2005         . .          .   .
                   0 1 2006         . .          .   .
                   0 1 2007         . .          .   .
                   0 1 2008 12.262413 .          .   4
                   0 1 2009 12.640274 .          0   4
                   0 1 2010  12.91715 .        .25   5
                   0 1 2011 13.302264 .         .4   7
                   0 1 2012  13.40613 .   .2857143   9
                   0 1 2013 13.318162 .   .5555556  14
                   0 1 2014 13.480266 .   .3571429  19
                   0 1 2015 13.552082 .          0  18
                   0 2 2004 16.320004 .          .   6
                   0 2 2005 16.259003 .          0   6
                   0 2 2006 16.325436 .          0   6
                   0 2 2007 16.249718 .          0   6
                   0 2 2008 16.329601 .  .16666667   7
                   0 2 2009 16.372135 .          0   7
                   0 2 2010 16.204067 .          0   6
                   0 2 2011 16.174494 .          0   6
                   0 2 2012 16.210453 .          0   6
                   0 2 2013 16.026436 .          0   6
                   0 2 2014 15.780373 .          0   4
                   0 2 2015 15.507068 .          0   4
                   0 3 2004 14.717526 .          .  46
                   0 3 2005  15.29863 .  .23913044  57
                   0 3 2006 14.427028 .          0  55
                   0 3 2007  13.07318 .          0  47
                   0 3 2008 11.988324 .          0  37
                   0 3 2009 11.322382 .          0  33
                   0 3 2010  11.74948 .   .3030303  43
                   0 3 2011 10.473407 .          0  27
                   0 3 2012  9.682564 .          0  16
                   0 3 2013 10.011105 .      .1875  19
                   0 3 2014  9.956585 .          0  15
                   0 3 2015  10.07903 .          0  11
                   0 4 2004 15.943534 .          . 152
                   0 4 2005  15.92585 .  .03947368 158
                   0 4 2006 16.102678 .   .0949367 173
                   0 4 2007 16.418432 .   .2485549 216
                   0 4 2008 16.437866 .   .1712963 253
                   0 4 2009 16.442644 .  .07509881 272
                   0 4 2010  16.34378 . .025735294 279
                   0 4 2011 16.335884 . .014336918 283
                   0 4 2012 16.232006 .  .03180212 292
                   0 4 2013 16.496168 .  .05821918 309
                   0 4 2014  17.09195 .  .05825243 327
                   0 4 2015  17.21494 .          0 324
                   0 5 2004         . .          .   .
                   0 5 2005         . .          .   .
                   0 5 2006         . .          .   .
                   0 5 2007   3.67482 .          .   1
                   0 5 2008         . .          .   .
                   0 5 2009         . .          .   .
                   0 5 2010         . .          .   .
                   0 5 2011         . .          .   .
                   0 5 2012         . .          .   .
                   0 5 2013         . .          .   .
                   0 5 2014         . .          .   .
                   0 5 2015         . .          .   .
                   1 6 2004 17.150093 .          .   1
                   1 6 2005 15.556746 .          0   1
                   1 6 2006 13.115322 .          0   1
                   1 6 2007   9.15078 .          0   1
                   1 6 2008  5.977219 .          0   1
                   1 6 2009  7.229989 .          0   1
                   1 6 2010         . .          .   .
                   1 6 2011         . .          .   .
                   1 6 2012         . .          .   .
                   1 6 2013         . .          .   .
                   1 6 2014         . .          .   .
                   1 6 2015         . .          .   .
    .582010582010582 7 2004         . .          .   .
    .582010582010582 7 2005         . .          .   .
    .582010582010582 7 2006         . .          .   .
    .582010582010582 7 2007 10.476154 .          .   1
    .582010582010582 7 2008 10.647244 .          0   1
    .582010582010582 7 2009 12.853146 .          0   1
    .582010582010582 7 2010 13.019257 .          0   1
    .582010582010582 7 2011 12.508344 .          0   1
    .582010582010582 7 2012 12.705505 .          0   1
    .582010582010582 7 2013  12.62807 .          0   1
    .582010582010582 7 2014 12.063735 .          0   1
    .582010582010582 7 2015  10.36172 .          0   1
                   0 8 2004 21.128635 .          . 133
                   0 8 2005  21.24772 .          0 129
                   0 8 2006 21.192095 .          0 108
                   0 8 2007  21.22827 .          0 103
                   0 8 2008  21.48543 .          0  99
                   0 8 2009 21.512186 .          0  89
                   0 8 2010  21.50318 .          0  82
                   0 8 2011  21.43127 . .024390243  84
                   0 8 2012 21.523424 .  .11904762  94
                   0 8 2013  21.72658 .  .05319149  99
                   0 8 2014 21.581614 .          0  99
                   0 8 2015  21.58638 .          0  94
                   0 9 2004 23.017605 .          .  33
                   0 9 2005  23.08483 .          0  33
                   0 9 2006   23.1325 .          0  32
                   0 9 2007 23.121153 .          0  32
    end
    where cem_weights are weights I would like to employ in a FE regression. The main problem is that when I try the code:
    Code:
    xtreg log_tot_sales recalled_dummy inflow_r nprod[aweight=cem_weights], fe
    the error of no observations appears. The total number of observations is 9681 and
    Code:
     count if cem_weights>0
     3288
    Thank you very much!

  • #2
    Federico:
    luckily enough, the issue is really trivial:
    Code:
    . sum recalled_dummy_byfirm
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
    recalled_d~m |          0
    Listwise deletion did the rest of the job and the unavoidable result is remaining with no observation to populate your regression model.
    Kind regards,
    Carlo
    (Stata 15.1 SE)

    Comment


    • #3
      I would fix the recalled_dummy variable.

      Code:
      replace recalled_dummy = 0 if recalled_dummy == . 
      xtreg log_tot_sales i.recalled_dummy inflow_r nprod[aweight=cem_weights], fe
      Note the use of factor notation on the recalled_dummy variable.

      Comment


      • #4
        Thank you all for the prompt reply,

        indeed I realize to have wrongly defined the dummy!

        Thank you very much!

        Comment

        Working...
        X