|
Size: 1361
Comment: Initial commit
|
← Revision 4 as of 2025-12-18 16:00:59 ⇥
Size: 1461
Comment: Link
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| = TsSet = | = Stata tsset = |
| Line 3: | Line 3: |
| The '''`tsset`''' command declares a time series dataset. | '''`-tsset-`''' declares a time series dataset. |
| Line 72: | Line 72: |
| ---- == See also == [[https://www.stata.com/manuals/tstsset.pdf|Stata manual for -tsset-]] |
Stata tsset
-tsset- declares a time series dataset.
Contents
Usage
. webuse gdp2
(Federal Reserve Economic Data, St. Louis Fed)
. tsset daten
Time variable: daten, 01jan1952 to 01oct2010, but with gaps
Delta: 1 day
. tsset tq
Time variable: tq, 1952q1 to 2010q4
Delta: 1 monthStata will indicate if there are gaps in observations. A common issue is misspecifying the time units (e.g., specifying a date for time series data that was collected weekly)
Operators
Time series variable operators:
L.foo = lagged reference
LN.foo = reference lagged by N time periods
F.foo = forward reference
FN.foo = reference forwarded by N time periods
D.foo = difference between L.foo and foo
DN.foo = difference between LN.foo and foo
S.foo = seasonal difference between L.foo and foo
SN.foo = seasonal difference between LN.foo and foo
Note also that the operators are case-insensitive.
As an example:
webuse gdp2 tsset tq // Create new variables generate l_gdp_ln = l.gdp_ln generate l_l_gdp_ln = l2.gdp_ln // Directly reference regress gdp_ln l.gdp_ln
Analysis
twoway (line gdp_ln tq)
