Example: air traffic controller

tsline — Time-series line plots - Stata

Time-series line plotsDescriptionQuick startMenuSyntaxOptionsRemarks and examplesReferencesAlso seeDescriptiontslinedraws line plots for Time-series a range plot with lines for Time-series startLine plot for the time seriesy1usingtssetdatatsline y1 Add plots of time seriesy2andy3tsline y1 y2 y3 Range plot with lines for the lower and upper values of time seriesy1stored iny1lowerandy1upper, respectivelytsrline y1_lower y1_upperOverlay a range plot of the lower and upper values of time seriesy1stored iny1lowerandy1upper, respectively, on a plot ofy1tsline y1 || tsrline y1_lower y1_upperMenuStatistics> time series >Graphs> line plots12 tsline Time-series line plotsSyntaxTime- series line plot [twoway]tslinevarlist[if][in][,tslin eoptions] Time-series range plot with lines[twoway]tsrliney1y2[if][in][,tsrlin eoptions]where the time variable is assumed set bytsset(see [TS]tsset),varlisthas the interpretationy1[ ].

Financial Econometrics Using Stata. College Station, TX: Stata Press. Cox, N. J. 2009a.Speaking Stata: Graphs for all seasons. Stata Journal 6: 397–419.. 2009b.Stata tip 76: Separating seasonal time series. Stata Journal 9: 321–326.. 2012.Speaking Stata: Transforming the time axis. Stata Journal 12: 332–341.

Tags:

  Series, Using, Time, Line, Silent, Financial, Econometrics, Stata, Plot, Tsline time series line plots, Financial econometrics using stata

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of tsline — Time-series line plots - Stata

1 Time-series line plotsDescriptionQuick startMenuSyntaxOptionsRemarks and examplesReferencesAlso seeDescriptiontslinedraws line plots for Time-series a range plot with lines for Time-series startLine plot for the time seriesy1usingtssetdatatsline y1 Add plots of time seriesy2andy3tsline y1 y2 y3 Range plot with lines for the lower and upper values of time seriesy1stored iny1lowerandy1upper, respectivelytsrline y1_lower y1_upperOverlay a range plot of the lower and upper values of time seriesy1stored iny1lowerandy1upper, respectively, on a plot ofy1tsline y1 || tsrline y1_lower y1_upperMenuStatistics> time series >Graphs> line plots12 tsline Time-series line plotsSyntaxTime- series line plot [twoway]tslinevarlist[if][in][,tslin eoptions] Time-series range plot with lines[twoway]tsrliney1y2[if][in][,tsrlin eoptions]where the time variable is assumed set bytsset(see [TS]tsset),varlisthas the interpretationy1[ ].

2 TslineoptionsDescriptionPlotsscatteropti onsany options documented in [G-2]graph twoway scatterwiththe exception ofmarkeroptionsandmarkerlabeloptions,whi ch will be ignored if specifiedY axis, time axis, Titles, Legend, Overall, Bytwowayoptionsany options documented in [G-3]twowayoptionstsrlineoptionsDescript ionPlotsrlineoptionsany options documented in [G-2]graph twoway rlineY axis, time axis, Titles, Legend, Overall, Bytwowayoptionsany options documented in [G-3]twowayoptionsOptions plots scatteroptionsare any of the options allowed by thegraph twoway scattercommand except thatmarkeroptionsandmarkerlabeloptionswi ll be ignored if specified; see [G-2]graph any of the options allowed by thegraph twoway rlinecommand; see [G-2]graphtwoway rline. Y axis, time axis, Titles, Legend, Overall, By twowayoptionsare any of the options documented in [G-3]twowayoptions.

3 These include optionsfor titling the graph (see [G-3]titleoptions), options for saving the graph to disk (see [G-3]sav-ingoption), and theby()option, which will allow you to simultaneously plot different subsetsof the data (see [G-3]byoption).Also see therecast()option discussed in [G-3]advancedoptionsfor information on how toplot spikes, bars, etc., instead of Time-series line plots 3 Remarks and are presented under the following headings:Basic examplesAdvanced exampleVideo exampleBasic examplesExample 1: A Time-series line plotWe simulated two separate time series (each of 200 observations) and placed them in a Statadataset, The first series simulates anAR(2)process with 1= and 2= ; thesecond series simulates anMA(2) process with 1= and 2= We usetslineto graphthese two use (Two simulated time series ).

4 Tsset lagsTime variable: lags, 0 to 199 Delta: 1 unit. tsline ar ma-101234050100150200 LagsSimulated AR(.8,.2)Simulated MA(.8,.2)Example 2: using options to highlight informationSuppose that we kept a calorie log for an entire calendar year. At the end of the year, we wouldhave a dataset (for example, ) that contains the number of calories consumed for 365days. We could then usetssetto identify the date variable andtslineto plot calories versus that we tend to eat a little more food on Thanksgiving and Christmas day, we use thettick()andttext()options to point out these days on the time tsline Time-series line plots . use (Simulated data of calories consumed for 365 days). tsset dayTime variable: day, 01jan2002 to 31dec2002 Delta: 1 day. tsline calories, ttick(28nov2002 25dec2002, tpos(in))> ttext(3470 28nov2002 "thanks" 3470 25dec2002 "x-mas", orient(vert))thanksx-mas3400360038004000 42004400 Calories consumed01jan200201apr200201jul200201oct 200201jan2003 DateOptions associated with the time axis allow dates (and times) to be specified in place of numericdate (and time ) values.

5 For instance, we usedttick(28nov2002 25dec2002, tpos(in))to place tick marks at the specified dates. This works similarly fortlabel(),tmlabel(), andtmtick().Suppose that we wanted to place vertical lines for the previously mentioned holidays. We couldspecify the dates in thetline()option as follows:. tsline calories, tline(28nov2002 25dec2002)340036003800400042004400 Calories consumed01jan200201apr200201jul200201oct 200201jan2003 Datetsline Time-series line plots 5 Example 3: Formatting the time axisWe could also modify the format of the time axis so that the labeled ticks display only the dayin the year:. tsline calories, tlabel(, format(%tdmd)) ttitle("Date (2002)")340036003800400042004400 Calories consumedJan1 Apr1 Jul1 Oct1 Jan1 Date (2002)Advanced exampletslineandtsrlineare both commands andplottypes as defined in [G-2]graph twoway.

6 Thusthe syntax fortslineis. graph twoway tsline .. twoway tsline .. tsline ..and similarly fortsrline. Being plot types, these commands may be combined with other plot typesin thetwowayfamily, as in,. twoway ( ) ( ) ( )..which can equivalently be written as. || || ||..6 tsline Time-series line plotsExample 4: Combining line and range plotsIn the first plot of example 2, we were uncertain of the exact values we logged, so we also gavea range for each day. Here is a plot of the summer tsrline lcalories ucalories if tin(1may2002,31aug2002) || tsline calories ||> if tin(1may2002,31aug2002), ytitle(Calories)330034003500360037003800 Calories01may200201jun200201jul200201aug 200201sep2002 DateCalorie rangeCalories consumedVideo exampleLine graphs and tin()ReferencesBoffelli, S., and G.

7 Urga. econometrics using Stata . College Station, TX: Stata , N. J. 2009a. Speaking Stata : Graphs for all Journal6: 397 2009b. Stata tip 76: Separating seasonal time Journal9: 321 2012. Speaking Stata : Transforming the time Journal12: 332 , M. F. 2019. Candle charts for financial technical Journal19: 200 , M. F., and J. D. Levendis. 2017. Technical financial analysis tools for Journal17: 736 see[TS]tsset Declare data to be Time-series data[G-2]graph twoway Twoway graphs[XT]xtline Panel-data line plots