Announcement

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

  • New variable containing data from earlier time period

    I have an unbalanced panel data set covering 20 years. Variable "performance" is only available every five years. I would like to create a new variable that is equal to "performance" five years earlier, otherwise missing value.

    I am familiar with the the L5.performance usage for xtreg, but that is a time-series command and cannot be used for procedure qreg

    Thanks. First time posting here. Hope I am clear.

  • #2
    Show us the results of xtset

    I think you have to worry that only a few data points will be available each panel for regressions using this variable.

    Comment


    • #3
      Thanks, but my question is not about the panel data. (I only use three years for which I have relevant data in the panel. I think this should be fine because each year has 300+ observations.)

      I want to use my panel data to do quantile regression (qreg). Quantile regression directly on a panel dataset is beyond my ability. So I am thinking of running qreg using a cross-section. But I would like to include a lagged dependent variable.

      I basically want to use L5.performance in my qreg regression. That is not possible (error code) so I need to find a work-around. My intention was to generate a new variable that is equal to the performance data five years earlier. I cannot use performance(_n-5) to generate a new variable because that just takes the data from five lines earlier.

      Comment


      • #4
        I can't advise further if you won't answer my question.

        How to calculate your lagged variable correctly depends on your xtset (or alternatively on knowing your exact data structure, but you haven't provided a data example and the report "unbalanced" makes me more than usually reluctant to guess). It's true, and I do understand, that qreg won't understand time series operators, so you need to create your lagged variables beforehand, which is why I need to know more before I can give good advice on how to do that.

        Comment


        • #5
          Apologies. Here is the xtset


          . xtset naics year, yearly
          panel variable: naics (unbalanced)
          time variable: year, 2002 to 2017, but with gaps
          delta: 1 year

          Comment


          • #6
            If your data are only for 2002 2007 2012 2017 (no other years present) then use delta(5)with xtset and the recipe for five years before is then

            Code:
            gen whatever5 = L1.whatever
            Otherwise use

            Code:
            gen whatever5 = L5.whatever
            The new variable is then a predictor in the quantile regression.



            Comment

            Working...
            X