MWPCA Procedure
OUTPUT Statement
OUTPUT OUT=libref.data-table <options>;
The OUTPUT statement creates an output data table to contain the results of the procedure run.
You must specify the following option:
- OUT=libref.data-table
-
names the output data table for PROC MWPCA to use. You must specify this option before any other options. libref.data-table is a two-level name, where
- libref
refers to a collection of information that is defined in the LIBNAME statement and includes the
library, which includes a path to where the data table is to be stored. For more information about libref, see the section Using SAS Viya Workbench.- data-table
specifies the name of the output data table.
You can also specify the following options:
-
NPC=number
NPCDISPLAYED=number specifies the number of principal components to display for each window in the output table.
- NPCUSED=number
specifies the number of principal components to be used to compute angle changes for each window in the output table.
- PCANGLES
-
displays the angle change of the principal components and the absolute angle of the first principal component in the output table. The angle change and the absolute angle track the change of the principal components over sliding windows. The range of both values is between 0 and 1, because both values are normalized by
, as shown by the following definitions:
-
The angle change of the first principal component is calculated by
where
and
are the first principal component vectors of two consecutive windows.
If the value of the NPCUSED= option is
, you use the following logic to compute the angle change. Consider the first
principal components that are associated with each of the windows. Consider these sets of principal components as sets of vectors. Each set of vectors defines a vector subspace. The subspace that a set of vectors spans is the set of all linear combinations of those vectors.
For example, the subspace that is associated with the vectors
and
in three-dimensional
space is the
plane. Each principal component is an
vector, and
principal components define a
-dimensional subspace of an
-dimensional space.
After the subspaces
and
are defined, you can calculate the angles between them. The first principal angle,
, is calculated as follows:
Let
and
be the subspaces of
and
, respectively, which are orthogonal to the values of
and
that maximize the previous equation. Then the following equation holds:
This process continues, with each new pair of subspaces being defined as orthogonal to all previously selected
and
. What results are
different angles.
You can rewrite the optimizations by using
and
, matrices whose columns are an orthonormal basis for
and
, respectively. Then you can write
and
, which finds the
that maximizes the following expression:
subject to
and
for all
. You can perform the optimization by using the singular value decomposition of
.
It is useful to convert the collection of angles to a single number for anomaly detection. Let
be a random variable that represents the collection of angles. If
and
are the mean and covariance of the distribution of
, respectively, then
can be calculated as a single summary number. If
is a multivariate normal distribution, then
is a
distribution with degrees of freedom equal to the dimension of
, which in this case is
. In practice, the mean or covariance of
is unknown, so they are estimated using a sliding-window sampling of a warmup data set. If no warmup data are specified, then
and
are set to the zero vector and identity matrix, respectively.
-
The absolute angle is calculated by
where
is the diagonal vector [1, 1, 1, …, 1] and
is the first principal component vector of the new observation.
-
-
SEED=number
RANDSEED=number specifies the seed of the pseudorandom number generator to use in warmup steps. If you do not specify a seed, or if you specify a value less than or equal to 0, the seed is generated by reading the time of day from the computer’s clock.
- STANDARDPC
-
standardizes the output principal components. If the window matrix is W and the ith principal component vector is
, then the jth element of the standard principal component
is
- WARMUPSIZE=number
specifies the number of observations to be used in warmup steps.
- WINSUMMARY=libref.data-table
-
specifies the name of the windows summary table that includes information about each window, such as rank of the low-rank matrix, number of iterations, number of observations that have missing values, and solution status. As a side note, observations that have missing values are omitted from the window.
libref.data-table is a two-level name, where libref refers to the library, 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 SAS Viya Workbench.