Skip to contents

Demonstration function to compute the sum of distances between consecutive cases in a time series.

Usage

psi_auto_distance(x = NULL, path = NULL, distance = "euclidean")

Arguments

x

(required, zoo object or matrix) univariate or multivariate time series with no NAs. Default: NULL

path

(optional, data frame) result of psi_cost_path_ignore_blocks(), only required if blocks in the least cost path were ignored. Default: NULL

distance

(optional, character vector) name or abbreviation of the distance method. Valid values are in the columns "names" and "abbreviation" of the dataset distances. Default: "euclidean".

Value

numeric value

Examples

#distance metric
d <- "euclidean"

#simulate zoo time series
x <- zoo_simulate(
  name = "x",
  rows = 100,
  seasons = 2,
  seed = 1
)

#sum distance between consecutive samples
psi_auto_distance(
  x = x,
  distance = d
)
#> [1] 6.921253