fdadist: Computes the distance matrix for functional data with...

View source: R/fdadist.R

fdadistR Documentation

Computes the distance matrix for functional data with amplitude and phase separation

Description

This function computes the matrix of pairwise distances between curves a functional data sample. This can be achieved with or without phase and amplitude separation, which can be done using a variety of warping classes.

Usage

fdadist(
  x,
  y = NULL,
  warping_class = c("affine", "dilation", "none", "shift", "srsf"),
  metric = c("l2", "pearson"),
  cluster_on_phase = FALSE,
  labels = NULL
)

Arguments

x

A numeric vector of length M or a numeric matrix of shape N \times M or an object of class funData::funData. If a numeric vector or matrix, it specifies the grid(s) of size M on which each of the N curves have been observed. If an object of class funData::funData, it contains the whole functional data set and the y argument is not used.

y

Either a numeric matrix of shape N \times M or a numeric array of shape N \times L \times M or an object of class fda::fd. If a numeric matrix or array, it specifies the N-sample of L-dimensional curves observed on grids of size M. If an object of class fda::fd, it contains all the necessary information about the functional data set to be able to evaluate it on user-defined grids.

warping_class

A string specifying the warping class Choices are "affine", "dilation", "none", "shift" or "srsf". Defaults to "affine". The SRSF class is the only class which is boundary-preserving.

metric

A string specifying the metric used to compare curves. Choices are "l2" or "pearson". Defaults to "l2". Used only when warping_class != "srsf". For the boundary-preserving warping class, the L2 distance between the SRSFs of the original curves is used.

cluster_on_phase

A boolean specifying whether clustering should be based on phase variation or amplitude variation. Defaults to FALSE which implies amplitude variation.

labels

A character vector specifying curve labels. Defaults to NULL which uses sequential numbers as labels.

Value

A stats::dist object storing the distance matrix between the input curves using the metric specified through the argument metric and the warping class specified by the argument warping_class.

Examples

idx <- c(1:5, 11:15, 21:25)
D <- fdadist(simulated30_sub$x[idx, ], simulated30_sub$y[idx, , ])

fdacluster documentation built on July 9, 2023, 6:45 p.m.