Learn R Programming

fdars (version 0.3.3)

register.fd: Curve Registration (Alignment)

Description

Aligns functional data by horizontal shifting to a target curve. This reduces phase variation in the sample.

Usage

register.fd(fdataobj, target = NULL, max.shift = 0.2)

Value

A list of class 'register.fd' with components:

registered

An fdata object with registered (aligned) curves.

shifts

Numeric vector of shift amounts for each curve.

target

The target curve used for alignment.

fdataobj

Original (unregistered) functional data.

Arguments

fdataobj

An object of class 'fdata'.

target

Target curve to align to. If NULL (default), uses the mean.

max.shift

Maximum allowed shift as proportion of domain (default 0.2).

Details

Shift registration finds the horizontal translation that maximizes the cross-correlation between each curve and the target. This is appropriate when curves have similar shapes but differ mainly in timing.

For more complex warping, consider DTW-based methods.

See Also

metric.DTW for dynamic time warping distance

Examples

Run this code
# Create phase-shifted curves
set.seed(42)
t <- seq(0, 1, length.out = 100)
X <- matrix(0, 20, 100)
for (i in 1:20) {
  phase <- runif(1, -0.1, 0.1)
  X[i, ] <- sin(2*pi*(t + phase)) + rnorm(100, sd = 0.1)
}
fd <- fdata(X, argvals = t)

# Register curves
reg <- register.fd(fd)
print(reg)

# Compare original vs registered
oldpar <- par(mfrow = c(1, 2))
plot(fd)
plot(reg$registered)
par(oldpar)

Run the code above in your browser using DataLab