Announcement

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

  • xtreg: What does "number of groups" report?

    Dear All,
    I ran some xtreg regressions and Stata reports number of groups. I thought this reports how many individuals are in the sample, but the number is higher (which puzzles me).

    Can someone enlighten me?

    Thanks in advance!

    Best

  • #2
    Jannic:
    as per FAQ, please post what you typed and what Stata gave you back. Thanks.
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      Carlo recommends the best approach to entice helpful replies.

      This being said, we shall keep in mind that, before - xtreg - , we - xtset - the data, hence we "group" according to the panel variable.

      You are supposed to get the number of groups aproximately equal to the number of observations divided by the average number of observations per group. Hence, the results shown in #1 are really unexpected, considering we - xtset - the data correctly.

      To reap less elusive replies, please act according to Carlo's advice.
      Best regards,

      Marcos

      Comment


      • #4
        Sure, sorry about that. I have time series data of yields of a large number of bonds, i.e. I use:
        Code:
        xtset bondid date
        xtreg yield controls
        Stata returns
        Code:
        Random-effects GLS regression       Number of obs = 7,994,426
        Group variable: bondid              Number of groups = 9,789
        to learn about the number of bonds in my sample I use:
        Code:
        egen bondtag = tag(bondid)
        egen totalbonds = total(bondtag)
        sum totalbonds
        totalbonds is now a variable that contains the total number of bonds in the sample. I would expect the number of groups be equal to or less than this number. Is this correct?

        Comment


        • #5
          So what exactly is it that worries you? You aren't showing the results from your last few commands.
          -------------------------------------------
          Richard Williams, Notre Dame Dept of Sociology
          Stata Version: 17.0 MP (2 processor)

          EMAIL: [email protected]
          WWW: https://www3.nd.edu/~rwilliam

          Comment


          • #6
            The result of the last few commands is that there appear to be only 8722 bonds in the sample (identified by the tag strategy above). this should NOT be possible right? I.e. i must a mistake somewhere else? At this point I am just wondering whether the "Number of groups" refers to the i=1...N dimension (and not the time dimension)

            Comment


            • #7
              If you give the -xtdes- command it will tell you how many groups you have. Or, do

              Code:
              codebook bondid
              Either of these would be a lot simpler than what you did.
              -------------------------------------------
              Richard Williams, Notre Dame Dept of Sociology
              Stata Version: 17.0 MP (2 processor)

              EMAIL: [email protected]
              WWW: https://www3.nd.edu/~rwilliam

              Comment

              Working...
              X