dist.array {FKmL}R Documentation

Compute Distance Array for Multidimensional Functional Data

Description

This function standardizes multidimensional functional data using provided scaling factors, computes pairwise Fréchet distances between trajectories for each variable, and returns a distance array (3-dimensional array of distance matrices).

Usage

dist.array(dt, time_scale, var_scales)

Arguments

dt

A long-format data.frame containing the following columns in the specified order:

  • ID: An identifier for each trajectory.

  • Time: The time points at which measurements were recorded (numeric or integer vector).

  • Variable1, Variable2, ... : The measured variables over time (numeric values). The data.frame should not include any missing values. See 'Details' for structure requirements.

time_scale

A single numeric value used to scale the Time column. This ensures that time is appropriately weighted relative to the variables.

var_scales

A numeric vector of scaling factors for the measured variables. Its length must be equal to ncol(dt) - 2.

Details

The dist.array function first applies scaling to the Time and each measured variable. Then, it computes pairwise Fréchet distances between trajectories for each variable separately. The output is a 3-dimensional array in which each slice corresponds to a variable-specific distance matrix.

Unlike the mfkml function, which requires at least three measurements across time for each trajectory, the SFKmL ((Sparse multi-dimensional Fréchet distance-based K-medoids for Longitudinal data), which uses dist.array, allows for trajectories with missing values, as long as each variable has at least three time points for each trajectory. Therefore, dt may include missing values.

Value

A numeric value or matrix. If form = "scalar", returns the Fréchet distance between the two trajectories as a single numeric value. If form = "matrix", returns the dynamic programming matrix used to compute the distance.

A 3-dimensional array of pairwise distances with dimensions [n, n, p], where:

n

Number of unique trajectories.

p

Number of variables.

Each slice [, , k] is a distance matrix for variable k.


[Package FKmL version 0.1.1 Index]