Announcement

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

  • Time variable in panel data

    Dear all,

    I am currently trying to define my first panel data set in Stata. For this, STATA (14.2) wants me to define a Panel ID variable and a Time variable. In my panel dataset I am looking at company transactions over 20 years. Accordingly, it happens that a company has also made more than one transaction per year. This brings us to the problem: Defining the panel ID variable is not a problem, since I can simply use the unique company ID, but when I define the time variable, STATA shows me the error that per time variable, i.e. in my case per year, each panel ID may only occur once.

    Various scientific papers also consider several transactions of a company per year and still were able to calculate for example xtlogit, fe or xtlogit, re. When I do this, above error message appears from Stata. One way to handle this problem - as far as I know - are multilevel analysis (mixed, melogit). But this does not correspond exactly to the logic xtlogit, fe or xtlogit, re. Another solution approach would be to aggregate the data so that I only have one transaction of a company per year but this would distort my calculations.

    Thus, how it is possible to run a xtlogit,fe or xtlogit, re in such a situation? How can I handle the definition problem with the time variable?

    Thank you very much for your supprt!




  • #2
    Tim:
    welcome to this foru,.
    The usual fix is to -xtset- your panel dataset with -panelid- only:
    Code:
    xtset panelid
    Unfortunately, this fix comes at the cost of not supporting time-series related commands, such as lags and leads.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hello Carlos,

      thank you very much for your answer. Does this mean that I can only use variables at time t? While my independent variables are calculated for t, my dependent variables are calculated for t till t+3 and my control variables are partially calculated for t and t-1.

      Thank you very much for your support!

      Comment


      • #4
        Tim:
        I meant that -xtset-ting your data with -panelid- only does not allow you to use the commands available from -tsset-.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Thank you very much, that was very understandable and helped me a lot.

          Comment


          • #6
            There are many angles on this. If there can be multiple transactions in a year and the number of transactions can vary from firm to firm and/or from year to year, then transactions will be irregularly spaced and the idea of lags and leads doesn't obviously make simple sense any way. Otherwise put, Stata's restrictions are intended just to mirror restrictions that are natural from a modelling point of view.

            Sometimes what people do is collapse to annual totals or means or whatever else makes sense.

            Comment


            • #7
              Otherwise put, Stata's restrictions are intended just to mirror restrictions that are natural from a modelling point of view.
              That is a very good hint, thank you very much!

              Comment


              • #8
                Unfortunately, this fix comes at the cost of not supporting time-series related commands, such as lags and leads.
                Another quick question:
                I want to generate instrumental variables to test for endogeneity. If I have it right in my head, the lagged values of the independent variables are often taken for this purpose. Can I do that in this setting at all, because, @Carlo meant that the functions lag and lead are not available to me?

                Comment

                Working...
                X