Computes the sum of distances between consecutive samples in a multivariate time-series. Required to compute the measure of dissimilarity
psi (Birks and Gordon 1985). Distances can be computed through the methods "manhattan", "euclidean", "chi", and "hellinger", and are implemented in the function
psi( least.cost = NULL, autosum = NULL, parallel.execution = TRUE)
character string, name of the column with time/depth/rank data. The data in this column is not modified.
dataframe with one or several multivariate time-series identified by a grouping column.
A list with named slots, each one with a psi value.
The measure of dissimilarity
psi is computed as:
least.cost - (autosum of sequences)) / autosum of sequences. It has a lower limit at 0, while there is no upper limit.
#loading data data(sequenceA) data(sequenceB) #preparing datasets AB.sequences <- prepareSequences( sequence.A = sequenceA, sequence.A.name = "A", sequence.B = sequenceB, sequence.B.name = "B", merge.mode = "complete", if.empty.cases = "zero", transformation = "hellinger" ) #computing distance matrix AB.distance.matrix <- distanceMatrix( sequences = AB.sequences, grouping.column = "id", method = "manhattan", parallel.execution = FALSE ) #computing least cost matrix AB.least.cost.matrix <- leastCostMatrix( distance.matrix = AB.distance.matrix, diagonal = FALSE, parallel.execution = FALSE ) AB.least.cost.path <- leastCostPath( least.cost.matrix = AB.least.cost.matrix, distance.matrix = AB.distance.matrix, parallel.execution = FALSE ) #extracting least cost AB.least.cost <- leastCost( least.cost.path = AB.least.cost.path, parallel.execution = FALSE ) #autosum AB.autosum <- autoSum( sequences = AB.sequences, least.cost.path = AB.least.cost.path, grouping.column = "id", parallel.execution = FALSE ) AB.autosum#> $`A|B` #>  46.86205 #>AB.psi <- psi( least.cost = AB.least.cost, autosum = AB.autosum, parallel.execution = FALSE ) AB.psi#> $`A|B` #>  2.263633 #>