Skip to contents

Extracts features from functional data by computing local averages over specified intervals. This is a simple but effective dimension reduction technique for functional data.

Usage

localavg.fdata(fdataobj, n.intervals = 10, intervals = NULL)

Arguments

fdataobj

An object of class 'fdata'.

n.intervals

Number of equal-width intervals (default 10).

intervals

Optional matrix of custom intervals (2 columns: start, end). If provided, n.intervals is ignored.

Value

A matrix with n rows (curves) and one column per interval, containing the local average for each curve in each interval.

Details

Local averages provide a simple way to convert functional data to multivariate data while preserving local structure. Each curve is summarized by its average value over each interval.

This can be useful as a preprocessing step for classification or clustering methods that require fixed-dimensional input.

Examples

# Create functional data
t <- seq(0, 1, length.out = 100)
X <- matrix(0, 20, 100)
for (i in 1:20) X[i, ] <- sin(2*pi*t) + rnorm(100, sd = 0.1)
fd <- fdata(X, argvals = t)

# Extract 5 local average features
features <- localavg.fdata(fd, n.intervals = 5)
dim(features)  # 20 x 5
#> [1] 20  5

# Use custom intervals
intervals <- cbind(c(0, 0.25, 0.5), c(0.25, 0.5, 1))
features2 <- localavg.fdata(fd, intervals = intervals)