Stata 11 help for twoway_tsline

help tsline dialogs: tsline twoway -------------------------------------------------------------------------------

Title

[TS] tsline -- Plot time-series data [G] graph twoway tsline -- Twoway line plots

Syntax

Time-series line plot

[twoway] tsline varlist [if] [in] [, tsline_options]

Time-series range plot with lines

[twoway] tsrline y_1 y_2 [if] [in] [, tsrline_options]

where the time variable is assumed set by tsset, varlist has the interpretation

y_1 [y_2 ... y_k]

tsline_options description ------------------------------------------------------------------------- Plots scatter_options any of the options allowed by [G] graph twoway scatter with the exception of marker_options, marker_placement_options, and marker_label_options, which will be ignored if specified

Y axis, Time axis, Titles, Legend, Overall, By twoway_options any options documented in [G] twoway_options -------------------------------------------------------------------------

tsrline_options description ------------------------------------------------------------------------- Plots rline_options any of the options allowed by graph twoway rline

Y axis, Time axis, Titles, Legend, Overall, By twoway_options any options documented in [G] twoway_options -------------------------------------------------------------------------

Menu

tsline and tsrline

Statistics > Time series > Graphs > Line plots

twoway tsline and twoway tsrline

Graphics > Twoway graph (scatter, line, etc.)

Description

tsline draws line plots for time-series data.

tsrline draws a range plot with lines for time-series data.

tsline and tsrline are both commands and plottypes as defined in [G] graph twoway. Thus the syntax for tsline is

. graph twoway tsline ...

. twoway tsline ...

. tsline ...

and similarly for tsrline. Being plot types, these commands may be combined with other plot types in the twoway family, as in,

. twoway (tsrline ...) (tsline ...) (lfit ...) ...

which can equivalently be written

. tsrline ... || tsline ... || lfit ... || ...

Options

+-------+ ----+ Plots +------------------------------------------------------------

scatter_options are any of the options allowed by the graph twoway scatter command except that marker_options, marker_placement_options, and marker_label_options will be ignored if specified; see [G] graph twoway scatter.

rline_options are any of the options allowed by the graph twoway rline command; see [G] graph twoway rline.

+------------------------------------------------+ ----+ Y axis, Time axis, Titles, Legend, Overall, By +------------------- twoway_options are any of the options documented in [G] twoway_options. These include options for titling the graph (see [G] title_options), options for saving the graph to disk (see [G] saving_option), and the by() option, which will allow you to simultaneously plot different subsets of the data (see [G] by_option).

Also see the recast() option discussed in [G] advanced_options for information on how to plot spikes, bars, etc., instead of lines.

Remarks

Example 1

We simulated two separate time series (each of 200 observations) and placed them in a Stata dataset, tsline1.dta. The first series simulates an AR(2) process with phi_1=0.8 and phi_2=0.2; the second series simulates an MA(2) process with theta_1=0.8 and theta_2=0.2. In the following we use tsline to graph these two series.

. sysuse tsline1, clear . tsset lags . tsline ar ma (click to run)

Example2

Suppose that we kept a calorie log for an entire calendar year. At the end of the year, we would have a dataset (e.g., tsline2.dta) that contains the number of calories consumed for 365 days. We could then use tsset to identify the date variable and use tsline to plot calories versus time. Knowing that we tend to eat a little more food on Thanksgiving and Christmas day, we use the ttick() and ttext() options to point these days out on the time axis.

. sysuse tsline2, clear . tsset day . tsline calories, ttick(28nov2002 25dec2002, tpos(in)) ttext(3470 28nov2002 "thanks" 3470 25dec2002 "x-mas" , orient(vert)) (click to run)

We were uncertain of the exact values we logged, so we also gave a range for each day. Here is a plot of the summer months.

. sysuse tsline2, clear . tsset day . tsrline lcalories ucalories if tin(1may2002,31aug2002) || tsline calories || if tin(1may2002,31aug2002), ytitle(Calories) (click to run)

Options associated with the time axis allow dates to be specified in place of elapsed time values. For instance, we used

ttick(28nov2002 25dec2002 , tpos(in))

to place tick marks at the specified dates. This works similarly for tlabel, tmlabel, and tmtick.

Suppose that we wanted to place vertical lines for the previously mentioned holidays. We could specify the dates in the tline() option as follows:

. sysuse tsline2, clear . tsset day . tsline calories, tline(28nov2002 25dec2002) (click to run)

We could also modify the format of the time axis so that only the day in the year is displayed in the labeled ticks:

. sysuse tsline2, clear . tsset day . tsline calories, tlabel(, format(%tdmd)) ttitle("Date (2002)") (click to run)

Also see

Manual: [TS] tsline [G] graph twoway tsline

Help: [TS] tsset; [XT] xtline; [G] graph twoway


© Copyright 1996–2010 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index