Functional Data Analysis (FDA)
High-performance Functional Data Analysis tools implemented in Rust with R bindings.
Packages
| Package | Language | Registry | Folder | Status |
|---|---|---|---|---|
| fdars | R | CRAN | sipemu/fdars-r | |
| fdars-core | Rust | crates.io | fdars-core/ |
Features
- Functional Data Operations: Mean, centering, derivatives, Lp norms, geometric median
- Depth Measures: Fraiman-Muniz, modal, band, modified band, random projection, random Tukey, functional spatial, kernel functional spatial, modified epigraph index
- Distance Metrics: Lp distances, Hausdorff, DTW, Fourier-based semimetric, horizontal shift semimetric
- Basis Representations: B-splines, Fourier basis, P-splines with GCV/AIC/BIC selection
- Clustering: K-means, fuzzy c-means with silhouette and Calinski-Harabasz validation
- Smoothing: Nadaraya-Watson, local linear, local polynomial, k-NN
- Regression: Functional PCA, PLS, ridge regression
- Outlier Detection: LRT-based outlier detection with bootstrap thresholding
- Seasonal Analysis: FFT, ACF, Autoperiod, CFDAutoperiod, SAZED period detection; seasonal strength metrics; amplitude modulation detection
Installation
R (fdars)
# From GitHub (requires Rust toolchain)
devtools::
# From binary release (no Rust required)
# Download from GitHub Releases, then:
# macOS
# Windows
Rust (fdars-core)
[]
= "0.3"
Or install from the repository:
[]
= { = "https://github.com/sipemu/fdars" }
Feature Flags
parallel(default): Enable rayon-based parallel processinglinalg: Enable linear algebra features (faer, ridge regression) — requires Rust 1.84+js: Enable WASM support with JS random number generation
For WASM builds, disable default features:
[]
= { = "0.3", = false }
Data Layout
Functional data is represented as column-major matrices stored in flat Vec<f64>:
- For n observations with m evaluation points:
data[i + j * n]gives observation i at point j - 2D surfaces (n observations, m1 x m2 grid): stored as n x (m1*m2) matrices
Quick Start
use ;
// Create sample functional data (3 observations, 10 points each)
let n = 3;
let m = 10;
let data: = .map.collect;
let argvals: = .map.collect;
// Compute mean function
let mean = mean_1d;
// Compute Fraiman-Muniz depth
let depths = fraiman_muniz_1d;
Examples
The fdars-core/examples/ directory contains 14 runnable examples progressing from basic to advanced:
| # | Example | Command | Topics |
|---|---|---|---|
| 01 | Simulation | cargo run -p fdars-core --example simulation |
KL expansion, eigenfunctions, noise |
| 02 | Functional Operations | cargo run -p fdars-core --example functional_operations |
Mean, centering, derivatives, norms, inner products |
| 03 | Smoothing | cargo run -p fdars-core --example smoothing |
Nadaraya-Watson, local linear/polynomial, k-NN |
| 04 | Basis Representation | cargo run -p fdars-core --example basis_representation |
B-splines, Fourier, P-splines, GCV/AIC/BIC |
| 05 | Depth Measures | cargo run -p fdars-core --example depth_measures |
8 depth measures, outlier ranking |
| 06 | Distances and Metrics | cargo run -p fdars-core --example distances_and_metrics |
Lp, Hausdorff, DTW, Fourier, h-shift |
| 07 | Clustering | cargo run -p fdars-core --example clustering |
K-means, fuzzy c-means, silhouette, CH index |
| 08 | Regression | cargo run -p fdars-core --example regression |
FPCA, PLS regression |
| 09 | Outlier Detection | cargo run -p fdars-core --example outlier_detection |
LRT bootstrap, depth confirmation |
| 10 | Seasonal Analysis | cargo run -p fdars-core --example seasonal_analysis |
FFT, ACF, Autoperiod, SAZED, peak detection |
| 11 | Detrending | cargo run -p fdars-core --example detrending |
Linear/polynomial/LOESS, STL decomposition |
| 12 | Streaming Depth | cargo run -p fdars-core --example streaming_depth |
Online depth, rolling windows |
| 13 | Irregular Data | cargo run -p fdars-core --example irregular_data |
CSR storage, regularization, kernel mean |
| 14 | Complete Pipeline | cargo run -p fdars-core --example complete_pipeline |
End-to-end: simulate → smooth → outliers → FPCA → cluster |
Performance
With the parallel feature (enabled by default), computationally intensive operations use rayon for multi-core performance. The library also supports WASM targets with sequential execution.
Documentation
- R Package: https://sipemu.github.io/fdars/
- Rust Crate: https://docs.rs/fdars-core
License
MIT