Speaking Stata: Identifying spells

Spells in time series (and more generally in any kind of one-dimensional series) may be defined as sequences of observations that are homogeneous in some sense. For example, a categorical variable may remain in the same state, or values of a measured variable may satisfy the same true–false condition. Devices for working with spells in Stata include marking the start of each spell with indicator variables and tagging spells with integer codes. Panel data are easy to handle with the by: prefix. Some kinds of spell identification require two passes through the data, as when only spells of some minimum length are of interest or short gaps are tolerable within spells. Many questions concerning spells are easy to answer given careful use of by: and appropriate sort order, selection of just 1 observation from each panel or spell, and appreciation of the many functions written for egen. Gaps before, between, and after spells can also be important, and I suggest a convention for handling them.


Issue Date:
2007
Publication Type:
Journal Article
DOI and Other Identifiers:
dm0029 (Other)
PURL Identifier:
http://purl.umn.edu/119273
Published in:
Stata Journal, Volume 07, Number 2
Page range:
249-265
Total Pages:
17

Record appears in:



 Record created 2017-04-01, last modified 2017-08-26

Fulltext:
Download fulltext
PDF

Rate this document:

Rate this document:
1
2
3
 
(Not yet reviewed)