Learn R Programming

MFPCA

MFPCA is an R-package for calculating a PCA for multivariate functional data observed on different domains, that may also differ in dimension. The estimation algorithm relies on univariate basis expansions for each element of the multivariate functional data.

Highlights

MFPCA allows to calculate a principal component analysis for multivariate (i.e. combined) functional data on up to three-dimensional domains:

  • Standard functional data defined on a (one-dimensional) interval.
  • Functional data with two-dimensional domains (images).
  • Functional data with three-dimensional domains (3D images, e.g. brain scans).

It implements various univariate bases:

  • Univariate functional PCA (only one-dimensional domains).
  • Spline bases (one- and two-dimensional domains; with optional smoothing penalty).
  • Cosine bases (two- and three-dimensional domains; fast implementation built on DCT).
  • Tensor PCA (two-dimensional domains; UMPCA approach from Lu et al. (2009) and FCP_TPA approach from Allen (2013)).
  • Given basis functions, e.g. from a previous univariate PCA.

The representation of the data is based on the object-oriented funData package, hence all functionalities for plotting, arithmetics etc. included therein may be used.

Installation

The MFPCA pacakge is available on CRAN. To install the latest version directly from GitHub, please use devtools::install_github("ClaraHapp/MFPCA") (install devtools before).

If you would like to use the cosine bases make sure that the C-library fftw3 is installed on your computer before you install MFPCA. Otherwise, MFPCA is installed without the cosine bases and will throw an error if you attempt to use functions that need fftw3.

Dependencies

The MFPCA package depends on the R-package funData for representing (multivariate) functional data. It uses functionalities from abind, foreach, irlba, Matrix, mgcv and plyr.

References

The theoretical foundations of multivariate functional principal component analysis are described in:

C. Happ, S. Greven (2018): Multivariate Functional Principal Component Analysis for Data Observed on Different (Dimensional) Domains. Journal of the American Statistical Association, 113(522): 649-659 .

For more details on the implementation, which is based on the funData package, and a case study, see:

C. Happ-Kurz (2020): Object-Oriented Software for Functional Data. Journal of Statistical Software, 93(5): 1-38 .

Bug reports

Please use GitHub issues for reporting bugs or issues.

Copy Link

Version

Install

install.packages('MFPCA')

Monthly Downloads

515

Version

1.3-11

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

Clara Happ-Kurz

Last Published

August 27th, 2025

Functions in MFPCA (1.3-11)

calcMFPCA

Internal function that implements the MFPCA algorithm for given univariate decompositions
MFPCA

Multivariate functional principal component analysis for functions on different (dimensional) domains
FCP_TPA

The functional CP-TPA algorithm
dct3D

Calculate and threshold DCT for an 3D image
dctBasis2D

Calculate a cosine basis representation for functional data on two- or three-dimensional domains
dct2D

Calculate and threshold DCT for an image
givenBasis

Use given basis functions for univariate representation
fcptpaBasis

Calculate a smooth PCA representation for functional data on two-dimensional domains
fdaBasis

Use a basis from package fda for univariate representation
expandBasisFunction

Calculate a linear combination of arbitrary basis function
dctFunction2D

Calculate linear combinations of orthonormal cosine basis functions on two- or three-dimensional domains
idct2D

Calculate an inverse DCT for an image
findAlphaVopt

Find the optimal smoothing parameters in FCP_TPA using GCV
.PACE

Calculate univariate functional PCA
gcv

Generalized cross-validation for the FCP-TPA algorithm
fpcaBasis

Calculate a functional principal component basis representation for functional data on one-dimensional domains
print.summary.MFPCAfit

Print summary of a Multivariate Functional Principal Component Analysis
scoreplot.MFPCAfit

Plot the Scores of a Multivariate Functional Principal Component Analysis
predict.MFPCAfit

Function prediction based on MFPCA results
print.MFPCAfit

Print the results of a Multivariate Functional Principal Component Analysis
plot.MFPCAfit

Plot MFPCA results
idct3D

Calculate an inverse DCT for a 3D image
scoreplot

Scoreplot Generic
multivExpansion

Calculate multivariate basis expansion
normVec

Calculate the euclidean norm of a vector
maxeig

Compute the largest eigenvalue and associated eigenvector of a matrix A using the power method
screeplot.MFPCAfit

Screeplot for Multivariate Functional Principal Component Analysis
splineBasis2D

Calculate a spline basis representation for functional data on two-dimensional domains
summary.MFPCAfit

Summarize a Multivariate Functional Principal Component Analysis
ttvCalculation

Internal function for the Tensor times Vector calculation
ttv

Tensor times vector calculation
splineBasis1D

Calculate a spline basis decomposition for functional data on one-dimensional domains
stratSample

Sample stratified indices according to a factor variable
univDecomp

Univariate basis decomposition
univExpansion

Calculate a univariate basis expansion
splineFunction2D

Calculate linear combinations of spline basis functions on two-dimensional domains
umpcaBasis

Calculate an uncorrelated multilinear principal component basis representation for functional data on two-dimensional domains
splineFunction1D

Calculate linear combinations of spline basis functions on one-dimensional domains
check_FCP_TPA_input

Check input of FCP TPA function
PACE

Univariate functional principal component analysis by smoothed covariance
UMPCA

UMPCA: Uncorrelated Multilinear Principle Component Analysis
calcBasisIntegrals

Utility function that calculates matrix of basis-scalar products (one dimension)