fda.usc_efic: Auxiliary functions for the 'goffda' package

fda.usc_eficR Documentation

Auxiliary functions for the goffda package

Description

Auxiliary functions required for the methods implemented in the goffda package, as enhancements of the auxiliary functions fdata.cen and func.mean from the fda.usc-package.

Usage

fdata_cen(X_fdata, mean_X = func_mean(X_fdata))

func_mean(X_fdata)

inprod_fdata(X_fdata1, X_fdata2 = NULL, int_rule = "trapezoid",
  as_matrix = TRUE, verbose = FALSE)

Arguments

X_fdata

sample of functional data as an fdata object of length n.

mean_X

functional mean of X_fdata.

X_fdata1, X_fdata2

samples of functional data as fdata objects of lengths n_1 and n_2, respectively. Sample sizes can be different.

int_rule

quadrature rule for approximating the definite unidimensional integral: trapezoidal rule (int_rule = "trapezoid") and extended Simpson rule (int_rule = "Simpson") are available. Defaults to "trapezoid".

as_matrix

flag to indicate if inprod_fdata returns a matrix or the vector of its lower triangular part in column-major order. Defaults to TRUE.

verbose

whether to show or not information about the inprod_fdata procedure.

Details

  • func_mean: computes the functional mean of X_fdata.

  • fdata_cen: centers the functional data X_fdata.

  • inprod_fdata(X_fdata1): computes as a row vector the elements of the lower triangular part of the inner products matrix (X_fdata vs X_fdata). If as_matrix = TRUE, the matrix of inner products is given.

  • inprod_fdata(X_fdata1, X_fdata2): computes the matrix of inner products (as_matrix = TRUE is forced) between X_fdata1 and X_fdata2.

Author(s)

Code iterated by Eduardo García-Portugués, Gonzalo Álvarez-Pérez, and Javier Álvarez-Liébana from the fda.usc-package originals.

Examples

## fdata_cen() vs fda.usc::fdata_cen()

data(phoneme, package = "fda.usc")
mlearn <- phoneme$learn[1:10, ]
plot(fda.usc::fdata.cen(mlearn)$Xcen)
plot(fdata_cen(mlearn))

## inprod_fdata() vs fda.usc::inprod.fdata()

# inprod_fdata between mlearn and mlearn: as a row vector

A <- fda.usc::inprod.fdata(fdata1 = mlearn)
A[upper.tri(A, diag = TRUE)]
inprod_fdata(X_fdata1 = mlearn, int_rule = "trapezoid", as_matrix = FALSE)

# inprod_fdata between mlearn and mlearn: as a matrix

A <- fda.usc::inprod.fdata(fdata1 = mlearn)
A
inprod_fdata(X_fdata1 = mlearn, int_rule = "trapezoid", as_matrix = TRUE)

# inprod_fdata between mlearn and mlearn2: as a matrix

mlearn2 <- phoneme$learn[11:30, ]
A <- fda.usc::inprod.fdata(fdata1 = mlearn, fdata2 = mlearn2)
A
B <- inprod_fdata(X_fdata1 = mlearn, X_fdata2 = mlearn2,
int_rule = "trapezoid", as_matrix = TRUE)
B

## Efficiency comparisons

microbenchmark::microbenchmark(fda.usc::fdata.cen(mlearn), fdata_cen(mlearn),
                               times = 1e3, control = list(warmup = 20))

microbenchmark::microbenchmark(fda.usc::inprod.fdata(fdata1 = mlearn),
                               inprod_fdata(X_fdata1 = mlearn,
                               as_matrix = FALSE), times = 1e3,
                               control = list(warmup = 20))


goffda documentation built on Oct. 14, 2023, 5:08 p.m.