Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: sequence analysis


From   [email protected] (Brendan Halpin)
To   [email protected]
Subject   Re: st: sequence analysis
Date   Thu, 05 Jan 2012 11:13:23 +0000

On Thu, Jan 05 2012, Melanie Spallek wrote:

> Hi, I'm trying to do a sequence analysis using housing trajectories
> (tenure status). I'm using sqset tenure id wave, trim to define my
> sequences. Followed by seqtab, so, I receive a frequency table of the
> sequences, however the so option treats identically all sequences that
> have the same order of elements; i.e., the sequence A-B-B-A would be
> treated the same as A-B-A-A, which is exactly what I want. My first (and
> most important) question is if and how I can save those sequences in a
> variable. Since my dataset is in long format, I'm aware that by having
> ten waves for each id, the 'sequence variable' will be occurring ten
> times, which is ok.

I would recommend using a string representation of the sequence, in
conjunction with Stata's regular expression functions. 

I have a set of sequence analysis utilities that are complementary to
SQ, that include a command to make strings from sequences. It is
available thus:

. net from http://teaching.sociology.ul.ie/sadi
. net install sadi

(depends on moremata, in turn available from SSC).

This includes a command -stripe- which creates a string representation
of the sequence. It works with wide format, so a reshape is needed:

. reshape wide tenure, i(id) j(wave)
. stripe tenure1-tenure10, gen(seqstr)
. tab seqstr if regexm(seqstr, "^A+B+A+$")

Regular expresssions are a little complicated but are a very good
way of specifying sequence patterns. This example goes from the start of
the sequence ("^") to the end ("$") and specifies that the sequence
consists of one or more As followed by one or more Bs followed by one or
more As. "+" means one or more, "*" means zero or more, "." matches
anything. 


Brendan
-- 
Brendan Halpin,   Department of Sociology,   University of Limerick,   Ireland
Tel: w +353-61-213147  f +353-61-202569  h +353-61-338562;  Room F1-009 x 3147
mailto:[email protected]    ULSociology on Facebook: http://on.fb.me/fjIK9t
http://teaching.sociology.ul.ie/bhalpin/wordpress         twitter:@ULSociology
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index