PV-WAVE Advantage > IMSL Statistics Reference Guide > Data Mining > UNSUPERVISED_ORDINAL_FILTER Procedure
UNSUPERVISED_ORDINAL_FILTER Procedure
Converts ordinal data into proportions. Optionally, it can also reverse encoding, accepting proportions and converting them into ordinal values.
Usage
UNSUPERVISED_ORDINAL_FILTER, x, z
Input Parameters
x—(Input/Output) An n_obs length integer array of ordinal classes, where n_obs is the number of observations and classes must be numbered 1 to n_classes. If keyword Decode is set, x is output
z—Array of length n_obs containing the encoded values for x represented as cumulative proportions associated with each ordinal class (values between 0.0 and 1.0 inclusive). This is an input parameter if Decode is specified, otherwise it is output.
Input Keywords
Double—If present and nonzero, double precision is used.
Decode—If Decode is specified, x is an output array and z is an input array that contains transformed cumulative proportions. In this case, the transformed cumulative proportions are converted into ordinal class values using the coding class = 1, 2, …, etc. Default: unset.
Square_root—If Square_root is specified, cumulative proportions are transformed using the square root transformation.
Arcsin—If Arcsin is specified, the cumulative proportions are transformed using the arcsin of the square root of the cumulative proportions.
No_transformNo_transform indicates that the cumulative proportions used to encode the ordinal variable are not transformed. Default: No_transform.
 
note
The Square_root, Arcsin, and No_transform keywords are mutually exclusive.
Output Keywords
N_classes—Number of ordinal classes in x and the number of unique proportions in z.
Discussion
UNSUPERVISED_ORDINAL_FILTER is designed to either encode or decode ordinal variables. Filtering consists of transforming the ordinal classes into proportions, with each proportion being equal to the proportion of the data at or below this class.
Ordinal Filtering: ENCODE
In this case, x is an input array that is filtered by converting each ordinal class value into a cumulative proportion.
For example, if x = {2, 1, 3, 4, 2, 4, 1, 1, 3, 3} then n_obs = 10 and N_classes = 4. This function then fills z with cumulative proportions represented as proportions displayed in the table below. Cumulative proportions are equal to the proportion of the data in this class or a lower class.
 
Cumulative Proportions
Ordinal Class
Frequency
Cumulative Proportion
1
3
30%
2
2
50%
3
3
80%
4
2
100%
If No_transform is specified, then the equivalent proportions in z are z = {0.50, 0.30, 0.80, 1.00, 0.50, 1.00, 0.30, 0.30, 0.80, 0.80}. If Square_root is specified, then the square root of these values is returned:
z = {0.71, 0.55 , 0.89, 1.0, 0.71, 1.0, 0.55, 0.55, 0.89, 0.89}.
If Arcsin is specified, then the arcsin square root of these values is returned using the following calculation:
Ordinal UnFiltering: DECODE
Ordinal Unfiltering takes the transformed cumulative proportions in z and converts them into ordinal class values using the coding class = 1, 2, …, etc.
For example, if No_transform is specified and z = {0.20, 1.00, 0.20, 0.40, 1.00, 1.00, 0.40, 0.10, 1.00, 1.00} then upon return, the output array would consist of the ordinal classes x = {2, 4, 2, 3, 4, 4, 3, 1, 4, 4}.
If one of the transforms is specified, the same operation is performed since the transformations of the proportions are monotonically increasing. For example, if the original observations consisted of {2.8, 5.6, 5.6, 1.2, 4.5, 7.1}, then input x for encoding would be x = {2, 4, 4, 1, 3, 5} and output N_classes = 5. The output array x after decoding would consist of the ordinal classes x = {2, 4, 4, 1, 3, 5}.
Example
In this example, if the Decode keyword is set, X is the output 1D array and Z is input array. If the Decode keyword is not set, X is the input 1D array and Z is output array.
; An array of length n_obs containing the classes for the ordinal
; data.
x = [2, 3, 4, 1, 4]
; Filtering.
UNSUPERVISED_ORDINAL_FILTER, x, z, N_classes=n_classes
; Unfiltering.
UNSUPERVISED_ORDINAL_FILTER, x2, z, /decode, N_classes=n_classes
PRINT, ""
PRINT, "n_classes = ", n_classes, Format = '(A19, I3)'
PRINT, ""
PM, LONG(x), Title = "X"
PRINT, ""
PM, z, Title = "Z"
PRINT, ""
PRINT, "n_classes = ", n_classes, Format = '(A19, I3)'
PRINT, ""
PM, x2, Title = "x-unfiltered"
Output
       n_classes =   4
 
X
           2
           3
           4
           1
           4
 
Z
     0.400000
     0.600000
     1.00000
     0.200000
     1.00000
 
       n_classes =   4
 
x-unfiltered
           2
           3
           4
           1
           4