Announcement

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

  • Panel ID in Trade Groups

    Hi, I am using the following data (Sample). I need to create a panel id which is uniquely identified. I have three trade groups and in every trade group, there is observation from every firm. Please have a look:

    Example generated by -dataex-. To install: ssc install dataex
    clear
    input double gvkey long date byte group double num_trades
    1004 19129 1 753
    1004 19130 1 984
    1004 19130 2 5
    1004 19131 1 954
    1004 19131 2 1
    1004 19134 1 1115
    1004 19135 1 1159
    1004 19136 3 1
    1004 19136 1 1643
    1004 19136 2 6
    1004 19137 1 945
    end
    format %d date

    I am trying to group gvkey by group or date but unable to have unique ids. Your advice on this will be highly appreciated.

    Thanks

  • #2
    I don't understand what you want.

    Your example data shows only a single firm (I assume gvkey is a firm identifier), which apparently belongs to all three trade groups. So in what sense do you want to "group gvkey by group or date." Please repost with an example that is more representative of your data, and then show what the results for that example might look like, along with a step-by-step explanation of how you arrived at those results.

    Comment


    • #3
      Clyde Schechter Thanks for your response. Yes, gvkey is the unique identifier. Group is the trade group. When I use xtset gvkey date I get repeated values error, which they are because of group variable. In every group, every firm is repeated. I also get the repeated values error when i group the gvkeys using egen id = group(gvkey) label . Please have a look at the data. Thanks

      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input double gvkey long date byte group double num_trades
      1004 20811 2 2
      1004 20815 1 1431
      1004 20815 2 3
      1004 20816 1 1502
      1004 20816 2 5
      1004 20817 2 3
      1004 20817 1 798
      1004 20818 1 891
      1004 20818 2 2
      1045 18995 1 9020
      1045 18995 3 1
      1045 18995 2 3
      1045 18996 1 5679
      1045 18996 3 1
      1045 18996 2 1
      1045 19701 2 744
      end
      format %d date

      Comment


      • #4
        I see the data, but I still do not understand what you want.

        What kind of analyses do you plan to do after you -xtset- your data. In particular, I do not understand what the relationship is between gvkey and group and what role these variables will play in your analyses.

        Let me also point out that you do not have to specify a time variable when you -xtset- your data. If your plan is simply to do fixed-effects analyses, with gvkey as the fixed effect, all you need is -xtset gvkey-. Stata will not then care whether there are repeated values. This version of the -xtset- command will enable you to do nearly all of the analyses you could do were you able to also specify a time variable. What you will lose is the ability to calculate lags, leads, seasonal differences or other time-series operations, and you will lose the ability to model autoregressive correlation structures. Those would not be applicable to a data structure such as the one you have in any case.

        Comment


        • #5
          gvkey is the firm id in data sets like Compustat.

          You appear to have multiple observations of numbers of trades for each firm in given days. Almost automatically, analyses of firm data use the firm as the panel.

          However, I'm not sure you really want separate observations for each group or just firm-year observations and then each group and the number of trades for that group as separate variables. This will depend on your specific model and research design on which we are ignorant. I'm not even sure what is your dv.

          Comment

          Working...
          X