Announcement

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

  • How to deal with Singleton Groups

    I am running three models comparing a Random Effects model, a Fixed Effects Model and a Fixed Effects Instrumental Variable model. For the FE regressions I am using xtivreg, which drops singleton groups. I would like to use the same data for the RE models. My number of observations should be the same for all three regressions. The RE regressions include singleton groups so N is higher. I have tried using e(sample) which did not work. I would like to drop singleton groups. I have tried:
    bys panelvar: drop if _N ==1 This also did not work as, it dropped more observations than singleton groups detected and causes the difference between my FE regressions and RE rgression observations to be even larger. Not sure how to go about this, any suggestions? Thanks!

  • #2
    Perhaps you made an error in your use of e(sample) but because you didn't show us what you did, it's difficult to tell you what to do differently.

    Something like the following should work.
    Code:
    xtiverg ... , fe ...
    generate to_use = e(sample)
    another_command .... if to_use, ...
    If it doesn't, please a few moments to review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question. It's particularly helpful to copy commands and output from your Stata Results window and paste them into your Statalist post using code delimiters [CODE] and [/CODE], and to use the dataex command to provide sample data, as described in section 12 of the FAQ.

    The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

    Section 12.1 is particularly pertinent

    12.1 What to say about your commands and your problem

    Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!
    ...
    Never say just that something "doesn't work" or "didn't work", but explain precisely in what sense you didn't get what you wanted.

    Comment


    • #3
      Thanks William. I have tried e(sample) as you suggested.

      Code:
       xtivreg y x1 x2 i.year fe
      gen use=e(sample)
      ivreg y x1 x2 i.year if use
      After running xtivreg I receive this message:
      Warning - singleton groups detected. 373 observation(s) not used.
      N for my FE regression is 12709 . N for my RE model is 13082 . The difference is equal to the number of singleton groups.

      Comment


      • #4
        Please run your sequence of commands again and this time, in the spirit of showing exactly what you typed and exactly what Stata typed in response, copy the commands and their full output from the Stata Results window and paste that into a CODE block as you used above,

        But first, consider that the xtivreg command you show seems to lack the specification of the instrumental variables, and lacks a comma before the fe option. The ivreg command seems inappropriate for your panel data; xtreg with the fe option is I think what you want for the FE model without IV, and xtreg with the re option for random effects.

        Comment

        Working...
        X