univExpansion function

Calculate a univariate basis expansion

Calculate a univariate basis expansion

This function calculates a univariate basis expansion based on given scores (coefficients) and basis functions.

univExpansion( type, scores, argvals = ifelse(!is.null(functions), functions@argvals, NULL), functions, params = NULL )

Arguments

  • type: A character string, specifying the basis for which the decomposition is to be calculated.
  • scores: A matrix of scores (coefficients) for each observation based on the given basis functions.
  • argvals: A list, representing the domain of the basis functions. If functions is not NULL, the usual default is functions@argvals. See funData and the underlying expansion functions for details.
  • functions: A functional data object, representing the basis functions. Can be NULL if the basis functions are not estimated from observed data, but have a predefined form. See Details.
  • params: A list containing the parameters for the particular basis to use.

Returns

An object of class funData with N observations on argvals, corresponding to the linear combination of the basis functions.

Details

This function calculates functional data Xi(t),i=1NX_i(t), i= 1 \ldots N

that is represented as a linear combination of basis functions bk(t)b_k(t)

Xi(t)=k=1Kθikbk(t),i=1,,N. X_i(t) = \sum_{k = 1}^K \theta_{ik} b_k(t), i = 1,\ldots, N.

The basis functions may be prespecified (such as spline basis functions or Fourier bases) or can be estimated from observed data (e.g. by functional principal component analysis). If type = "default" (i.e. a linear combination of arbitrary basis functions is to be calculated), both scores and basis functions must be supplied.

Warning

The options type = "spline2Dpen", type = "DCT2D" and type = "DCT3D" have not been tested with ATLAS/MKL/OpenBLAS.

Examples

oldPar <- par(no.readonly = TRUE) par(mfrow = c(1,1)) set.seed(1234) ### Spline basis ### # simulate coefficients (scores) for N = 10 observations and K = 8 basis functions N <- 10 K <- 8 scores <- t(replicate(n = N, rnorm(K, sd = (K:1)/K))) dim(scores) # expand spline basis on [0,1] funs <- univExpansion(type = "splines1D", scores = scores, argvals = list(seq(0,1,0.01)), functions = NULL, # spline functions are known, need not be given params = list(bs = "ps", m = 2, k = K)) # params for mgcv plot(funs, main = "Spline reconstruction") ### PCA basis ### # simulate coefficients (scores) for N = 10 observations and K = 8 basis functions N <- 10 K <- 8 scores <- t(replicate(n = N, rnorm(K, sd = (K:1)/K))) dim(scores) # Fourier basis functions as eigenfunctions eFuns <- eFun(argvals = seq(0,1,0.01), M = K, type = "Fourier") # expand eigenfunction basis funs <- univExpansion(type = "uFPCA", scores = scores, argvals = NULL, # use argvals of eFuns (default) functions = eFuns) plot(funs, main = "PCA reconstruction") par(oldPar)

See Also

MFPCA, splineFunction1D, splineFunction2D, splineFunction2Dpen, dctFunction2D, dctFunction3D, expandBasisFunction