help twed

Title

twed -- Calculate inter-sequence distances using Time-Warp Edit Distance

Syntax

twed varlist , options [option]

options

Cost structure
subsmat(matname) use matname as the substitution cost matrix

lambda(#) use # as the lambda parameter

nu(#) use # as the nu parameter

Sequence length length(var) sequence
length, a variable or a constant if sequence length is fixed

Distances pwdist(matname) store the
pairwise distances in matname, as a symmetric matrix. Will be
created or overwritten.

ref(integer) (Optional) compare all sequences to the first N sequences, instead of calculating all pairwise distances.

Work-space workspace (Optional) Causes the internal
workspace matrices to be shown for each sequence comparison.

Normalisation STAndard (Optional) If "longer", normalise by the length of the longer sequence, if "none" do no normalisation. Defaults to "none".

Description

twed calculates Marteau's Time-Warp Edit Distance (TWED)
between all pairs of sequences in the data, where varlist is a
consecutive set of variables describing the elements of the sequence.
Time-warping stretches and compresses the time dimension to achieve
alignment in a manner similar but not identical to oma's
insertion and deletion. Marteau (2007) describes a time-warping
algorithm with a stiffness parameter (nu) and a gap penalty (lambda)
which is metric as long as nu>0 (many time-warping distances are not
metric). Because it uses compression instead of deletion, it respects
the spell structure of the trajectory more than oma does. It uses
a matching cost operation that is very close to OMA's substitution
operation. The algorithm also differs by comparing adjacent pairs of
elements in each sequence, rather than single elements.

It uses a Stata plugin implementation.

States must be numbered as consecutive integers from 1 up, and the
substitution cost matrix must be square, with dimension equal to the
number of states. States must not be missing.

References

Halpin, Brendan. (2014). Three narratives of sequence
analysis, Bühlmann et al (eds), Advances in Sequence Analysis.
Beyond the Core Program, Springer

Marteau, P.-F. (2007).
Time Warp Edit Distance with Stiffness Adjustment for Time Series
Matching.
ArXiv Computer Science e-prints.

Marteau, P.-F. (2008).
Time Warp Edit Distance.
ArXiv e-prints, 802.

Author

Brendan Halpin, brendan.halpin@ul.ie

Examples

. matrix scost = (0,1,2,3\1,0,1,2\2,1,0,1\3,2,1,0)

. twed m1-m36, subsmat(scost) lambda(0.5) nu(0.15) pwdist(dist) len(36)

. matrix list dist

. twed m1-m72, subsmat(scost) lambda(0.5) nu(0.15) pwdist(dist) len(dur)

. matrix list dist