The HMM Procedure
PROC HMM Statement
PROC HMM DATA=CAS-libref.data-table <options>;
The PROC HMM statement invokes the HMM procedure. You must specify the following option:
- DATA=CAS-libref.data-table
-
names the input data table for PROC HMM to use. CAS-libref.data-table is a two-level name, where
- CAS-libref
refers to a collection of information that is defined in the LIBNAME statement and includes the
caslib, which includes a path to the data, and a session identifier, which defaults to the active session but which can be explicitly defined in the LIBNAME statement. For more information about CAS-libref, see the section Using CAS Sessions and CAS Engine Librefs.- data-table
specifies the name of the input data table.
You can also specify the following options:
- LABELSWITCH=(options)
-
specifies the order in which to label the states (and components). The label switching problem is a common issue for HMMs because any two HMMs are mathematically equivalent if the only difference between two models is that the states are labeled in different ways. For example, consider the following two univariate bistate Gaussian HMMs, which are described by the parameters
, where
is the initial state probability vector,
is the transition probability matrix,
,
and
are mean and covariance parameters for state 1, and
and
are mean and covariance parameters for state 2:
In theory, these two models are equivalent, and just the state labels “1” and “2” are switched. When the labels are switched, it is inconvenient to compare any state-related results, such as filtered or smoothed probabilities or decoded path. The LABELSWITCH= option helps you define the order of the state (and component) labels. You can specify the following options:
- OUT=CAS-libref.data-table
writes the changes of state labels (and component labels in the case of GM HMMs) to the specified output data table. CAS-libref.data-table is a two-level name, where CAS-libref refers to the
casliband session identifier, and data-table specifies the name of the output data table. For more information about this two-level name, see the DATA= option and the section Using CAS Sessions and CAS Engine Librefs.- REORDER=(number-list)
specifies the new order of the state labels, where the number-list directly specifies the new order of the states. The number-list must be a permutation of numbers 1 to K, where K is the number of states; that is, the size of the number-list must be K, and each element in the number-list must be unique and between 1 and K. For example, REORDER=(3 1 2) implies that the original state 1 becomes state 3, state 2 becomes state 1, and state 3 becomes state 2. If you specify this option, the SORT= option is ignored.
- REORDERCOMPONENT=(number-list)
specifies the new order of the component labels in the case of GM HMMs, where the number-list directly specifies the new order of the components for each state. For a K-state M-component GM HMM, the size of the number-list,
, must be
, and each sublist
must be a permutation of numbers 1 to M—that is, each element in the sublist
must be unique and between 1 and M. For example, REORDERCOMPONENT=(3 2 1 2 1 3) for a bistate tricomponent GM HMM implies that the original components 1, 2, and 3 for the original state 1 become components 3, 2, and 1, respectively, for the original state 1, and the original components 1, 2, and 3 for the original state 2 become components 2, 1, and 3, respectively, for the original state 2. If you specify this option, the labels for components in each state are not sorted.
- SORT=type <(name-list)>
-
specifies whether to sort the labels of states (and components) and in which type of order. You can specify the following types:
- ASC <(name-list)>
sorts the labels in ascending order. You can add a name-list in parentheses in order to sort the labels of states (and components). The possible names that can appear in the name-list are ISPV, TPM, MCP, CPM, LAMBDA, MU, SIGMA, CONST, SDUMMY, LTREND, QTREND, XL, AR, and COV; the meanings of those names are defined in Table 4. Any parameters that are not in the model are ignored.
- DESC <(name-list)>
sorts the labels in descending order. You can add a name-list in parentheses in order to sort the labels of states (and components). The possible names that can appear in the name-list are ISPV, TPM, MCP, CPM, LAMBDA, MU, SIGMA, CONST, SDUMMY, LTREND, QTREND, XL, AR, and COV; the meanings of those names are defined in Table 4. Any parameters that are not in the model are ignored.
- NONE
does not sort the labels.
By default, if the INMODEL= option is not specified in the SCORE statement, SORT=ASC(SIGMA); otherwise, SORT=NONE. For example, when the ESTISPV option is not specified, the ISPV is not in the stationary HMM; if you include ISPV in the name-list, it is ignored. For a GM HMM, the labels of components for each state are first sorted by the parameters state by state if the REORDERCOMPONENT= option is not specified; then the labels of states are sorted by the parameters that are stacked in the new order of components.
For more details and examples, see the section Label Switching Problem.
- OUTSTAT=CAS-libref.data-table
writes the log likelihood and information criteria to the specified output data table. The information criteria include Akaike’s information criterion (AIC), the corrected Akaike’s information criterion (AICC), the Bayesian information criterion (BIC, also referred to as the Schwarz Bayesian criterion, SBC), and the Hannan-Quinn criterion (HQC). CAS-libref.data-table is a two-level name, where CAS-libref refers to the
casliband session identifier, and data-table specifies the name of the output data table. For more information about this two-level name, see the DATA= option and the section Using CAS Sessions and CAS Engine Librefs.- SEED=number
specifies a nonnegative integer to use as the seed for generating random number sequences. When the seed value is 0, random number sequences are generated by using the time of day from the computer’s clock. Seed values greater than 0 generate reproducible random number sequences. By default, SEED=1.