help trans2subs

Title

trans2subs -- Create substitution matrix based on observed transitions

Syntax

trans2subs state [if] [in], IDvar(id) SUBSmat(subsmat) [DIAGincl]

Description

trans2subs calculates a substitution matrix based on
observed transitions in the state variable, and puts it in the
subsmat matrix. The data must be in long format, with
idvar identifying the groups, and must be sorted.

Transitions are tabulated from period to period, and the
substitution cost is defined as 2 - p_ - p for
off-diagonal cells, and 0 for diagonal cells. p_ is defined as
the proportion of transitions from a in t which are to b in t+1.
Note that, by default, cases which do not have a transition from
one period to the next do not enter the calculation.

Options

IDvar(idvar) specifies the ID variable.

SUBSmat(mat) specifies the Stata matrix to which to write the substitution costs.

DIAGincl causes the cells on the diagonal to be used in the calculation.

Comments

One way to define substition costs for optimal matching is to
use observed transition rates between states. Higher probabilities
of transition imply greater similarity. This may often be a
good idea, but it is not always the case. It is plausible that in
some domains we will see high probabilities of transition between
states which are substantively quite dissimilar, for instance
between never-married and married.

The procedure expects the data in long calendar format, that is
with each record representing a person--month or case--time-unit,
sorted in temporal order within IDvar, the variable identifying the
person or case. The resulting matrix is based on a cross-tabulation
of state at t and t-1.

In this format only off-diagonal cases represent transitions:
the diagonal represents months where the state is the same as the
previous month. In the default, the diagonal cases are excluded,
but the option DIAGincl causes them to be included in the
calculation. Including them reduces the range of the substitution costs.

The strategy is based in part on that described in Rowher and
Potter's TDA manual, section 6.7.2.5,
http://www.stat.ruhr-uni-bochum.de/pub/tda/doc/tman63/d06070205.zip

Author

Brendan Halpin, brendan.halpin@ul.ie

Examples

If your sequences are represented by consecutive variables
s1-s50 with ID id, first reshape long:

. reshape long s, i(id) j(m)

. trans2subs s, id(id) subs(smat)

. matrix list smat

. trans2subs s, id(id) subs(smat) diag

. matrix list smat2

. reshape wide