Announcement

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

  • How to declare a time variable in a Panel Data where the time variable repeats itself?

    Hello everyone,

    I'm currently working with longitudinal panel data across multiple countries. My time variable, "Date," repeats itself (for the various countries e.g. Jan-2015 will repeat for all the countries), which is preventing me from using xtset to declare the time variable. Is there a workaround for creating lagged variables in this situation?

    Thank you for your help!

  • #2
    Based on what you've described, if there are no other variables to work with, no there is no workaround because it is mathematically impossible to even define a lagged variable in this circumstance. So, let's say that there are two (or more) observations for India and Jan-2015. Suppose you also have two observations for India in Feb-2015, there is no way to decide which of those India Jan-2015 observations should be considered the lag for which of the Feb-2015 observations.

    If, in fact, you have some way for deciding which observation would be the lag for which, then, that needs to be incorporated in your data set in terms of other variables. (Examples of other variables might be economic sectors, or provinces/states, or demographic subgroups, and so on.) And in that case, the panel variable needs to be a combination of country and that (those) other variable(s). To create a panel variable that incorporates multiple variables, see -help egen- and scroll down to the -group()- function. Then you can use -xtset- with the grouped panel variable and the date variable.

    Comment


    • #3
      Shbham:
      welcome to this forum.
      As an aside to Clyde's helpful insight, you cannot use time-series opeartors (such as lags and leads) if you do not -xtset- your dataset with -timevar- too.
      I agree with Clyde's point that using the -group- function available from -egen- is a viable solution, provided that, I would add, you get yourself familiar with the implications of your composite -panelid- when interpreting -xtreg- results.
      Kind regards,
      Carlo
      (StataNow 18.5)

      Comment


      • #4
        Thank you for your responses Clyde Schechter and Carlo Lazzaro.

        Comment

        Working...
        X