align_fPCA: Group-wise function alignment and PCA Extractions

View source: R/align-fpca.R

align_fPCAR Documentation

Group-wise function alignment and PCA Extractions

Description

This function aligns a collection of functions while extracting principal components.

Usage

align_fPCA(
  f,
  time,
  num_comp = 3L,
  showplot = TRUE,
  smooth_data = FALSE,
  sparam = 25L,
  parallel = FALSE,
  cores = NULL,
  max_iter = 51L,
  lambda = 0
)

Arguments

f

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

time

A numeric vector of length M specifying the grid on which functions f have been evaluated.

num_comp

An integer value specifying the number of principal components to extract. Defaults to 3L.

showplot

A boolean specifying whether to display plots along the way. Defaults to TRUE.

smooth_data

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

sparam

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

parallel

A boolean specifying whether computations should run in parallel. Defaults to FALSE.

cores

An integer value specifying the number of cores to use for parallel computations. Defaults to NULL in which case it uses all available cores but one. This argument is only used when parallel == TRUE.

max_iter

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

lambda

A numeric value specifying the elasticity. Defaults to 0.0.

Value

A list with the following components:

  • f0: A numeric matrix of shape M \times N storing the original functions;

  • 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;

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

  • mqn: A numeric vector of length M storing the mean SRSF;

  • gam: A numeric matrix of the same shape as f0 storing the estimated warping functions;

  • vfpca: A list storing information about the vertical PCA with the following components:

    • q_pca: A numeric matrix of shape (M + 1) \times 5 \times \mathrm{num\_comp} storing the first 3 principal directions in SRSF space; the first dimension is M + 1 because, in SRSF space, the original functions are represented by the SRSF and the initial value of the functions.

    • f_pca: A numeric matrix of shape M \times 5 \times \mathrm{num\_comp} storing the first 3 principal directions in original space;

    • latent: A numeric vector of length M + 1 storing the singular values of the SVD decomposition in SRSF space;

    • coef: A numeric matrix of shape N \times \mathrm{num\_comp} storing the scores of the N original functions on the first num_comp principal components;

    • U: A numeric matrix of shape (M + 1) \times (M + 1) storing the eigenvectors associated with the SVD decomposition in SRSF space.

  • Dx: A numeric vector of length max_iter storing the value of the cost function at each iteration.

References

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 <- align_fPCA(simu_data$f, simu_data$time)

## End(Not run)

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