time_warping: Alignment of univariate functional data

View source: R/time-warping.R

time_warpingR Documentation

Alignment of univariate functional data

Description

This function aligns a collection of 1-dimensional curves that are observed on the same grid.

Usage

time_warping(
  f,
  time,
  lambda = 0,
  penalty_method = c("roughness", "geodesic", "norm"),
  centroid_type = c("mean", "median"),
  center_warpings = TRUE,
  smooth_data = FALSE,
  sparam = 25L,
  parallel = FALSE,
  optim_method = c("DP", "DPo", "DP2", "RBFGS"),
  max_iter = 20L
)

Arguments

f

A numeric matrix of shape M \times N specifying a sample of N curves observed on a grid of size M.

time

A numeric vector of length M specifying the common grid on which all curves f have been observed.

lambda

A numeric value specifying the elasticity. Defaults to 0.0.

penalty_method

A string specifying the penalty term used in the formulation of the cost function to minimize for alignment. Choices are "roughness" which uses the norm of the second derivative, "geodesic" which uses the geodesic distance to the identity and "norm" which uses the Euclidean distance to the identity. Defaults to "roughness".

centroid_type

A string specifying the type of centroid to align to. Choices are "mean" or "median". Defaults to "mean".

center_warpings

A boolean specifying whether to center the estimated warping functions. Defaults to TRUE.

smooth_data

A boolean specifying whether to smooth curves using a box filter. Defaults to FALSE.

sparam

An integer value specifying the number of times to apply the box filter. Defaults to 25L. This is used only when smooth_data = TRUE.

parallel

A boolean specifying whether to run calculations in parallel. Defaults to FALSE.

optim_method

A string specifying the algorithm used for optimization. Choices are "DP", "DPo", "DP2", and "RBFGS". Defaults to "DP".

max_iter

An integer value specifying the maximum number of iterations. Defaults to 20L.

Value

An object of class fdawarp which is a list with the following components:

  • time: a numeric vector of length M storing the original grid;

  • f0: a numeric matrix of shape M \times N storing the original sample of N functions observed on a grid of size M;

  • q0: a numeric matrix of the same shape as f0 storing the original SRSFs;

  • fn: a numeric matrix of the same shape as f0 storing the aligned functions;

  • qn: a numeric matrix of the same shape as f0 storing the aligned SRSFs;

  • fmean: a numeric vector of length M storing the mean or median curve;

  • mqn: a numeric vector of length M storing the mean or median SRSF;

  • warping_functions: a numeric matrix of the same shape as f0 storing the estimated warping functions;

  • original_variance: a numeric value storing the variance of the original sample;

  • amplitude_variance: a numeric value storing the variance in amplitude of the aligned sample;

  • phase_variance: a numeric value storing the variance in phase of the aligned sample;

  • qun: a numeric vector of maximum length max_iter + 2 storing the values of the cost function after each iteration;

  • lambda: the input parameter lambda which specifies the elasticity;

  • centroid_type: the input centroid type;

  • optim_method: the input optimization method;

  • inverse_average_warping_function: the inverse of the mean estimated warping function;

  • rsamps: TO DO.

References

Srivastava, A., Wu, W., Kurtek, S., Klassen, E., Marron, J. S., May 2011. Registration of functional data using Fisher-Rao metric, arXiv:1103.3817v2.

Tucker, J. D., Wu, W., Srivastava, A., Generative models for functional data using phase and amplitude Separation, Computational Statistics and Data Analysis (2012), 10.1016/j.csda.2012.12.001.

Examples

## Not run: 
  out <- time_warping(simu_data$f, simu_data$time)

## End(Not run)

fdasrvf documentation built on Nov. 19, 2023, 1:09 a.m.