Adaptive Functional Principal Component Analysis
- Authors: Angel Garcia de la Garza, Britton Sauerbrei, Jeff Goldsmith
- License: MIT. See the LICENSE file for details
- Version: 0.9
afpca implements Adaptive Functional Principal Component Analysis (aFPCA), a method for estimating directions of variation in functional data that exhibit sharp changes in smoothness. Standard FPCA methods impose a global smoothness assumption that can fail to capture abrupt transitions in the underlying signal. afpca addresses this by combining a fast and scalable adaptive scatterplot smoothing technique with a probabilistic FPCA framework, allowing functional principal components to be smoothed adaptively. This is particularly useful in applications such as neural recordings, where sharp changes in activity following a stimulus must be distinguished from smooth baseline behavior.
You can install the development version of afpca from GitHub with:
install.packages("devtools")
devtools::install_github("angelgar/afpca")These are examples of running adaptive FPCA. More details of the use of the package can be found in XYZ.
The code below uses a the function
afpca::simulate_adaptive_functional_data() to simulate 20 curves
-
$\mu(t) = t^{-3/2}$ $\sin(\pi \times t^{1/4})I(t>1/2)$ -
$\phi_k(t) = t^{-3/2}$ $\sin(4\pi \times k \times t^{1/4})I(t>1/2), k = 1,2$
library(afpca)
simulated_data <- simulate_adaptive_functional_data(N.subj = 20)The plot below show what this simulated data looks like:
Our software performs adaptively-smoothed functional principal component
analysis. The main function in our package to do this is
afpca:fpca.adapt. The code below illustrates how to do this:
afpca.output <- fpca.adapt(data = simulated_data)The plots below show the estimated mean function and functional principal components
The plots below shows two examples of observed functions and the respective reconstructions.
This package includes vignette articles that reproduce all figures and analyses from the accompanying paper. These vignettes are intended to ensure full reproducibility of the results presented in the manuscript.
The vignette source files are available locally within the package
directory at ./vignettes/articles/. They can also be viewed online via
the package’s documentation site:
Garcia de la Garza A, Sauerbrei B, Goldsmith J (2026). afpca: Adaptive Functional Principal Component Analysis. R package version 0.0.0.9, https://github.com/angelgar/afpca.


