pub fn functional_acf(
data: &FdMatrix,
argvals: &[f64],
max_lag: Option<usize>,
n_sim: usize,
ci: f64,
seed: u64,
) -> Result<FacfResult, FdarError>Expand description
Functional autocorrelation and partial autocorrelation of a curve series.
Computes the L2-norm functional ACF at lags 1..=max_lag following the
fdaACF convention (Mestre et al. 2021), the scalar Durbin-Levinson fPACF,
and Monte-Carlo strong-white-noise confidence bands.
§Arguments
data— Time-ordered functional observations (N × m, column-major). Rows are curves ordered from earliest to latest.argvals— Evaluation points on the common grid (lengthm).max_lag— Maximum lag to compute.Noneusesmin(20, N/4).n_sim— Monte-Carlo replications for the white-noise band (default 999).ci— Confidence level for the upper band (default 0.95).seed— Deterministic RNG seed for the MC band.
§Errors
FdarError::InvalidDimension—datais empty,argvals.len() != m, or the requestedmax_lag + 1 > N(too few curves).FdarError::InvalidParameter—max_lag == 0(must be ≥ 1), orn_sim == 0(must be ≥ 1), orciis not in the open interval(0.0, 1.0).FdarError::ComputationFailed— the lag-0 covariance diagonal integrates to near zero (degenerate / constant-curve input).
§Algorithm
- Compute the sample mean curve and Simpson quadrature weights.
- Compute the m×m lag-0 sample autocovariance operator C_0 (normalised by 1/N).
- For each h = 1..=max_lag, compute C_h and
ρ_h = sqrt(‖C_h‖²_HS) / normalizationwherenormalization = ∫ C_0(t,t) dt(trace integral, trapezoidal). - Eigendecompose C_0 via
nalgebra::SymmetricEigen; truncate eigenvalues withλ_j / λ_max < 1e-4. - Run
n_simMC draws ofQ = Σ_{j,k} λ_j λ_k χ²_1(j,k)to obtain theci-quantile;upper_band[h] = sqrt(q_ci) / normalization. - Apply scalar Durbin-Levinson to
acfto obtainpacf.
§Divergence from R fdaACF
White-noise band: fdaACF offers both an exact Imhof band (via the
CompQuadForm R package) and a Monte-Carlo path. This implementation
provides the Monte-Carlo approximation only — no pure-Rust Imhof
equivalent exists without adding a new crate dependency. The MC path
converges as n_sim → ∞; the default n_sim = 999 matches fdars’
permutation-test convention (use 10 000 for publication-quality bands).
fPACF: see functional_pacf for the Durbin-Levinson divergence note.