Announcement

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

  • Label Time-Series Graph

    Hello,
    for my research I have performed time-series analysis. To smooth out fluctuations, I have averaged values over every 3 years, means that I compressed 3 different values (2004 = 5 ; 2005 = 7 ; 2006 = 9 ) to one value (2004 – 2006 = 7 , since (5+7+9)/3 = 7).
    Now I try to display this in a time-series graph, but I have problems with labeling my time–axis. My aim is that the time-axis reflects those 3 year periods. So it should look like this:

    –––––––––––––––––––––––––––––––––––––––––––
    | 2004 - 2006 | 2007 - 2009 | 2010 - 2012

    So basically the problem is not creating the graph, but labeling the axis so that you can see that the respective value is an average over multiple years.
    I did some research and found the command – xlabel –. However, it didn't solve my problem so far.
    Any help is appreciated – thanks in advance !
    Best regards,
    Sebastian

  • #2
    See http://www.stata-journal.com/sjpdf.h...iclenum=gr0030 for detailed discussion.

    Note incidentally that xlabel() is an option, not a command.

    Comment


    • #3
      Hello Nick,

      thank you very much for your fast and helpful answer. It almost perfectly did the job
      I have used the following command:

      tsline SI_NI_Magnitude, xtick(170(12)216, tlength(12)) xlabel(172(4)216, noticks format(%tqCY))

      My graph looks now like this:
      -------------------------------------------------------------------------------------------
      | 2003 2004 2005 | 2006 2007 2008 | 2009 2010 2011 | 2012 2013 2014

      If possible it should look like this:
      -------------------------------------------------------------------------------------------
      | 2003 - 2005 | 2006 - 2008 | 2009 - 2011 | 2012 - 2014

      The main issues why i cannot do this so far is because:
      1) I don't know how to leave out the interim year (2004,2007...) and replace it with a "-"
      2) the erratic intervals. If i change my command by tsline SI_NI_Magnitude, xtick(170(12)216, tlength(12)) xlabel(172(8)216, noticks format(%tqCY)) ... then the output of course shows me every third year. However, actually I need every third year (2003-2005), then the next year (2005 | 2006) , then every third year again ...

      Would appreciate any help!!!
      Thanks in advance !!




      Comment


      • #4
        Dear Sebastian,

        I think you should use the option -tlabel-, adding this one to your current code
        Code:
        tlabel(2003 2005 2006 2008 2009 2011 2012 2014)
        Hope it works well for you, Sebastian.

        Comment


        • #5
          It seems that you want e.g. the text "2003-2005" at the point 2004. That doesn't call for special machinery, but just spelling that out. I'd create a year variable to make it all easier.

          Showing your data would make exact suggestions possible.

          Comment


          • #6
            Thank you both Thong & Nick - your recommendations have been very helpful. I got now exactly what I want.
            best regards,
            Sebastian
            Last edited by Sebastian Roth; 29 Mar 2017, 12:35.

            Comment

            Working...
            X