help tsvarlist
-------------------------------------------------------------------------------
Title
[U] 11.4.4 Time-series varlists
Description
Time-series varlists are a variation on varlists of existing variables.
When a command allows a time-series varlist, you may include time-series
operators. For instance, L.gnp refers to the lagged value of variable
gnp. The time-series operators are
Operator Meaning
---------------------------------------------------------
L. lag (x_t-1)
L2. 2-period lag (x_t-2)
...
F. lead (x_t+1)
F2. 2-period lead (x_t+2)
...
D. difference (x_t - x_t-1)
D2. difference of difference (x_t - 2x_t-1 + x_t-2)
...
S. "seasonal" difference (x_t - x_t-1)
S2. lag-2 (seasonal) difference (x_t - x_t-2)
...
---------------------------------------------------------
Remarks
1. Time-series operators may be repeated and combined. L3.gnp refers
to the third lag of variable gnp, as do LLL.gnp, LL2.gnp, and
L2L.gnp.
2. The lead operator F. is the complement of the lag operator L., so
FL.gnp is just gnp.
3. Note that D1.gnp equals S1.gnp, but D2.gnp does not equal S2.gnp
because
D2.gnp = (gnp_t - gnp_t-1) - (gnp_t-1 - gnp_t-2)
= gnp_t - 2*gnp_t-1 + gnp_t-2
while
S2.gnp = (gnp_t - gnp_t-2)
4. Operators may be typed in lowercase or uppercase.
5. Operators can be typed in any order; Stata will convert the
expression to its canonical form. For example, Stata will convert
ld2ls12d.gnp to L2D3S12.gnp.
6. In addition to operator#, Stata understands operator(numlist) to
mean a set of operated variables. For example, specifying
L(1/3).gnp
in a varlist is the same as typing
L.gnp L2.gnp L3.gnp
7. In operator#, making # zero returns the variable itself. Thus,
instead of typing
regress y x L(1/3).x
you can save a few keystrokes by typing
regress y L(0/3).x
8. Before using time-series operators, you must declare the time
variable using tsset.
. list l.gnp
time variable not set
r(111)
. tsset time
(output omitted)
. list l.gnp
(output omitted)
9. Variable names can be abbreviated subject to the usual Stata
conventions. If the only variable in your dataset that begins with
gn is gnp, then you can type L.gn instead of L.gnp
10. The time-series operators respect the time variable. L2.gnp refers
to gnp_t-2 regardless of missing observations in the dataset.
Notice in the following dataset that the observation for 1992 is
missing:
+------------------------+
| year gnp L2.gnp |
|------------------------|
1. | 1989 5452.8 . |
2. | 1990 5764.9 . |
3. | 1991 5932.4 5452.8 |
4. | 1993 6560.0 5932.4 | <- Note, filled in correctly
5. | 1994 6922.4 . |
6. | 1995 7237.5 6560.0 |
+------------------------+
11. Time-series operators work with panel data as well as pure
time-series data. The only difference is in how you tsset your
data.
Examples
. webuse gxmpl1
. list cpi L.cpi L2.cpi L3.cpi
. list cpi L(1/3).cpi
. list cpi L2.cpi LL.cpi
. list cpi F.cpi F2.cpi F3.cpi
. list cpi F2.cpi FF.cpi
. generate cpi_diff = cpi[_n] - cpi[_n-1]
. list cpi cpi_diff D.cpi
. list cpi D.cpi S.cpi D2.cpi S2.cpi
Also see
Manual: [U] 11.4.4 Time-series varlists
Help: [U] 11 Language syntax,
[U] 11.1.8 numlist,
[U] 11.4 varlists,
[U] 13.7 Explicit subscripting,
[TS] tsset