Time Series Analysis Package
SIMILARITY Method
rc = TSA.SIMILARITY (x, y, <'type'>, <'scale'>, <expandpct>, <expandabs>, <compresspct>, <compressabs>, <measure>);
The SIMILARITY function analyzes the similarity between two time series.
Required Arguments
You must specify the following arguments, separated by a comma:
- x
specifies the input time series array to be compared to the target time series.
- y
specifies the target time series array to be compared to the input time series.
Optional Arguments
You can also specify the following arguments, separated by commas. If you want to use a default value for any of these arguments, enter a space for it.
- 'type'
-
specifies the similarity measure.
You can specify the following values within single quotation marks:
- ABSDEV
specifies the absolute deviation.
- MABSDEV
specifies the mean absolute deviation.
- MABSDEVINP
specifies the mean absolute deviation relative to the length of the input sequence.
- MABSDEVMAX
specifies the mean absolute deviation relative to the maximum valid path length.
- MABSDEVMIN
specifies the mean absolute deviation relative to the minimum valid path length.
- MABSDEVTAR
specifies the mean absolute deviation relative to the length of the target sequence.
- MSQRDEV
specifies the mean squared deviation.
- MSQRDEVINP
specifies the mean squared deviation relative to the length of the input sequence.
- MSQRDEVMAX
specifies the mean squared deviation relative to the maximum valid path length.
- MSQRDEVMIN
specifies the mean squared deviation relative to the minimum valid path length.
- MSQRDEVTAR
specifies the mean squared deviation relative to the length of the target sequence.
- SQRDEV
specifies the squared deviation.
The default value is SQRDEV.
- 'scale'
-
specifies how the working input sequence is scaled with respect to the working target sequence. Scaling is performed after normalization.
You can specify the following values within single quotation marks:
- ABS
applies absolute scaling.
- NONE
applies no scaling.
- STD
applies standard scaling.
The default value is NONE.
- expandpct
specifies the warping expansion as a percentage of the length of the target sequence, where expandpct ranges from 0 to 100, 0 implies no compression, and 100 implies maximum allowable compression. The default value is 100.
- expandabs
specifies the absolute warping expansion, where expandabs is an integer that ranges from 0 to 10,000. The default is the maximum allowable absolute expansion.
- compresspct
specifies the warping compression as a percentage of the length of the target sequence, where compresspct ranges from 0 to 100, 0 implies no compression, and 100 implies maximum allowable compression. The default value is 100.
- compressabs
specifies the absolute warping compression, where compressabs is an integer that ranges from 0 to 10,000. The default is the maximum allowable absolute compression.
Returned Values
The SIMILARITY function returns the following values:
- rc
-
returns one of the following scalar return codes:
rc Termination Reason 4 Warping limits relaxed 3 Expansion limits relaxed 2 Compression limits relaxed 1 Warping limits imposed 0 Success < 0 Computational failure
Optional Returned Values
You can also specify the following arguments, separated by commas, to request additional returned values. If you do not want the value to be returned, enter a space for it.
- measure
returns the similarity measure.
Example
This example uses the TSMODEL procedure to compute the similarity of two time series arrays: x and y.
data test;
input i x1 x2 x3 y1 y2 y3 r;
datalines;
1 3 2 4 2 3 2 1
2 5 4 5 4 5 3 1
3 3 3 4 6 4 5 1
4 3 6 6 7 6 7 1
5 3 5 5 3 5 7 1
6 6 6 6 8 8 8 1
7 3 8 5 9 9 8 1
8 8 9 8 3 7 3 1
9 6 7 6 8 4 9 1
10 7 9 8 9 6 7 1
;
run;
data mylib.testsim;
set test;
run;
proc tsmodel data=mylib.testsim
outscalar=mylib.sim_scalar
nthreads=1;
require tsa;
id i interval=day;
var x1 y1;
outscalars measure;
submit;
declare object TSA(tsa);
rc = TSA.SIMILARITY(x1, y1, 'absdev', 'NONE', , , , ,measure);
endsubmit;
run;