EconPapers    
Economics at your fingertips  
 

Speaking Stata: Identifying spells

Nicholas Cox

Stata Journal, 2007, vol. 7, issue 2, 249-265

Abstract: 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.

Keywords: spells; runs; time series; data management (search for similar items in EconPapers)
Date: 2007
References: View references in EconPapers View complete reference list from CitEc
Citations: View citations in EconPapers (1)

Downloads: (external link)
http://www.stata-journal.com/article.html?article=dm0029

Related works:
This item may be available elsewhere in EconPapers: Search for items with the same title.

Export reference: BibTeX RIS (EndNote, ProCite, RefMan) HTML/Text

Persistent link: https://EconPapers.repec.org/RePEc:tsj:stataj:v:7:y:2007:i:2:p:249-265

Ordering information: This journal article can be ordered from
http://www.stata-journal.com/subscription.html

Access Statistics for this article

Stata Journal is currently edited by Nicholas J. Cox and Stephen P. Jenkins

More articles in Stata Journal from StataCorp LLC
Bibliographic data for series maintained by Christopher F. Baum () and Lisa Gilmore ().

 
Page updated 2025-03-29
Handle: RePEc:tsj:stataj:v:7:y:2007:i:2:p:249-265