Announcement

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

  • Linear time trend

    Dear all,

    I have data on the 2nd quarter from 1999 to 2008.I want to create a linear time trend, I tried with gen Trend=_n but I´m not sure if it is right.

    Thanks!

  • #2
    Assuming your data are sorted in year order, that will work.
    Richard T. Campbell
    Emeritus Professor of Biostatistics and Sociology
    University of Illinois at Chicago

    Comment


    • #3
      This works if your data are ordered by year and quarter. It also assumes what you label Trend is a variable in your data set.

      Comment


      • #4
        I do not have any trend variable in my dataset, just a variable that indicates the year and a variable that refers to 2nd quarter. Thus, do you mean that if I create a trend like that it will be wrong?

        Comment


        • #5
          Might be, might not be: it depends on the sort order of your data. In general I would consider relying on the sort order a rather unsafe way of creating such variables (what if you have two or more observations in the same year/quarter?) Instead I would just create a Stata time variable. Say your year variable is called year and your quarter variable is called quarter, then you could type gen time = yq(year, quarter). You can make the data look prettier by following that with the command format time %tq. For more see help datetime.
          ---------------------------------
          Maarten L. Buis
          University of Konstanz
          Department of history and sociology
          box 40
          78457 Konstanz
          Germany
          http://www.maartenbuis.nl
          ---------------------------------

          Comment


          • #6
            Ok, I´m very grateful for your comment.

            Comment

            Working...
            X