Announcement

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

  • Adding Three Linear Time Trends to a Regression with Repeated Time Values

    Hello,

    I am trying to add in three separate yearly linear time trends into a regression. I have data that has events from 1984-2013 with some events occurring multiple times per year. I am trying to separate the trends by three different waves: (1984-1989), (1990-1999), and (2000-2013). Does anyone know how I can go about to do this? I am unable to use the command tsset due to an error of "repeated values in my sample." Another option I thought would work would be to define three dummy variables for each wave and include that into my regression, but I am unsure that the dummy variable method will capture the effect of a linear time trend.

    Best,
    Eric C.

  • #2
    An additional piece of information I forgot to include was that I do not have observations for the years 1988-1990, 2009, or 2012

    Comment


    • #3
      Here's the basis to an approach for including three separate yearly trends. Background information from help factor variables to understand what this is doing. I think adding ibn.wave#c.year to your independent variables will give you three time trend lines. But view this response as advice on the Stata mechanics, not on the statistics. Further disclaimer is that there are more sophisticated ways of doing this that yield a single trend line with bends in it, but that too is beyond the scope of this response.
      Code:
      clear
      input year
      1984
      1985
      1986
      1987
      1991
      1992
      1993
      1994
      1995
      1996
      1997
      1998
      1998
      2000
      2001
      2002
      2003
      2004
      2005
      2005
      2007
      2010
      2011
      2013
      end
      generate wave = .
      replace wave=1 if year<=1989
      replace wave=2 if year>1989 & year<=1999
      replace wave=3 if year>1999
      list year wave ibn.wave#c.year, sepby(wave) noobs

      Comment


      • #4
        One remark about William's good advice. His model including year, wave, and their interaction produces three separate trend lines, one for each of the waves. In some situations, however, the expectation would be that the lines should meet at the boundaries of adjacent waves, so that overall the trend line bends at wave boundaries but remains connected. The contrary situation, implemented in William's model, is that in addition to a change in direction as we move from one wave to the next, there can also be a "shock" or "bump" that resets the baseline at that time. Which model is more appropriate depends on your specific situation.

        If you want a trend line that bends but has no jumps at wave boundaries have a look at linear spines, -help mkspline-.

        Comment


        • #5
          Clyde - Many thanks for filling in the gap in my response, and pointing us to mkspline. That prompted me to read the help file and realize mkspline is substantially different than my previous experience with splines using JMP. It would be really easy to use mkspline for the purpose I was grasping at that you described well.

          Comment

          Working...
          X