help cal2spell

Title

cal2spell -- Create spell-format variables from wide calendar format variables

Syntax

cal2spell, options

options

Options
state(string) Stub of state variable name, in reshape fashion

spellvar(string) Stub of spell state-variable name (will be created)

length(string) Stub of spell length-variable name (will be created)

nspells(varname) number-of-spells variable (will be created)

Description

cal2spell takes variables representing sequence data in wide calendar format
(i.e., a consecutive string of numbered state variables representing
state in each time unit, with one case per sequence) and creates
wide spell format variables (consecutive pairs of numbered state and duration
variables) with a separate variable indicating the number of spells.

It returns the maximum number of spells observed in r(maxspells)
and the range of the state variable in r(nels).

This can be used to prepare the data for combinadd and
other techniques that focus on spell history rather than state history.

Spells are defined as consecutive runs of the same state in the
calendar variables.

Note: this replaces combinprep, and differs from it in that
it retains both the calendar and spell format representations, rather
than replacing the calendar with the spell variables.

Author

Brendan Halpin, brendan.halpin@ul.ie

Examples

Given sequences represented as consecutive variables s1-s40:

. cal2spell, state(s) spell(sp) length(dur) nspells(nsp)

will generate a new structures with variable pairs sp1,
dur1 to spX, durX where X is the maximum number of
spells observed. The spells are defined as consecutive runs in the same
state, and their duration is recorded in the dur variable. The
observed number of spells in each case is recorded in nsp.