Announcement

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

  • Time Series Graph Percentage Deviations from Trend

    Hello,

    I am currently working on time series analysis, trying to identify the effect of an increase in income on consumption.
    Therefore I have quarterly data from 1990 to 2019.
    To get a better overview of the development I want to graph the variables consumption and income as percentage deviations from trend over time.
    However I only get this outcome:

    I use the command:

    [twoway (tsline d.y) (tsline d.c)]

    Does anybody know how I need to change the code in order to get percentage deviations from trend?

    Thank you very much in advance!




  • #2
    How do you define trend? Do you mean a percent based on (value - trend ) / trend or something else?

    Comment


    • #3
      Hello Nick,

      Attached you can see the time plot of the income variable which is following a positive trend. Now I want to analyze the percentage deviations from the trend (f.ex. in year 2008 or 2013). The graph should look like the second attachment.
      I tried a lot of commands but I was not successful.

      Maybe you can support me

      Attached Files

      Comment


      • #4
        Hello Nick,

        I think I found a solution using the code

        [gen dy=d.y/l.c]

        Correct me if I am wrong but this should solve my problem since the result should display the growth rate of income relativ to the level of the prior period.

        Am I right?

        Comment


        • #5
          That does what it does, but I would not regard it as measuring deviation from trend.

          Comment


          • #6
            Ok then how would you suggest to proceed?

            Comment


            • #7
              Perhaps this can give you some guidance

              Code:
              clear
              
              * Real Gross Domestic Product (GDPC1)
              local series = "GDPC1"
              !curl -L https://fred.stlouisfed.org/series/`series'/downloaddata/`series'.csv > "`series'.csv"
              insheet using "`series'.csv", comma clear
              erase "`series'.csv"
              
              ren value gdp
              
              gen quarter = qofd(date(date, "YMD"))
              format quarter %tq
              tsset quarter, quarterly
              tsfilter hp gdp_trend =  gdp
              
              gen gdp_dev = (gdp_trend/gdp) * 100
              
              tsline gdp_dev if yofd(dofq(quarter)) <= 2011, xtitle("Year") ///
                     ytitle("Percentage Deviation from Trend") xlab(, format(%tqCY)) ylab(, angle(h))
              Click image for larger version

Name:	gdp.png
Views:	1
Size:	442.8 KB
ID:	1550740

              Comment


              • #8
                Justin Blasongame gave a nice answer. In effect, Justin is implying what I asked in #2. How do you define trend? IANAE (*) but I see in #3 an unsurprising change of pattern after 2008. Do you want that to be part of your trend or is it a deviation? It would be possible by write down many different methods for identifying a trend, and all hinges on your choice.


                (*) I Am Not An Economist. Needed here alongside FWIW and AFAIK and so forth. A search shows that it has already been invented, which is reassuring.

                Comment


                • #9
                  Nick Cox, AFAIK and FWIW, you are the 29th best ranked economist in the world.

                  https://ideas.repec.org/top/top.person.all.html

                  Comment


                  • #10
                    https://www.merriam-webster.com/dict...0ben%20trovato

                    Comment


                    • #11
                      Thank you very much for your answers.
                      #8: Actually I am a beginner in time series analysis and I want to generate a graph representing my time series data adequately. I define a trend as indicating that (in this case) income increases without anything other happening than time passing.
                      What do you mean with an unsurprising change of pattern? Do you mean that income has decreased as a consequence of financial crisis ? Until now it is part of my analysis but I am considering to exclude the year from my regression.

                      Comment


                      • #12
                        That is not a definition of trend which I can relate to any precise technique. I meant that 2008 seems to have had a discernible impact.

                        Comment

                        Working...
                        X