fda.usc (version 2.0.1)

metric.DTW: DTW: Dynamic time warping

Description

Computes distances time warping for functional data

Usage

metric.DTW(fdata1, fdata2 = NULL, p = 2, w = min(ncol(fdata1), ncol(fdata2)))

metric.WDTW( fdata1, fdata2 = NULL, p = 2, w = min(ncol(fdata1), ncol(fdata2)), wmax = 1, g = 0.05 )

metric.TWED(fdata1, fdata2 = NULL, p = 2, lambda = 1, nu = 0.05)

Arguments

fdata1

Functional data 1 or curve 1. If fdata class, the dimension of fdata1$data object is (n1 x m), where n1 is the number of curves and m are the points observed in each curve.

fdata2

Functional data 2 or curve 2. If fdata class, the dimension of fdata2$data object is (n2 x m), where n2 is the number of curves and m are the points observed in each curve.

p

Lp norm, by default it uses p = 2

w

Vector of weights with length m, If w = 1 approximates the metric Lp by Simpson's rule. By default it uses w = 1

wmax

numeric maximum value of weight, (1 by default)

g

numeric g=0 (constant), 0.05 (linear) by default, 0.25 sigmoid, 3 two weight values

lambda

numeric lambda value (0 by default)

nu

numeric constant value, (0 by default)

Value

DTW matrix

Details

Three optins:

  • DTW: Dynamic time warping

  • WDTW: Weight Dynamic time warping

  • TWED: twed

References

Jeong, Y. S., Jeong, M. K., & Omitaomu, O. A. (2011). Weighted dynamic time warping for time series classification. Pattern Recognition, 44(9), 2231-2240

See Also

See also semimetric.basis and semimetric.NPFDA

Examples

Run this code
# NOT RUN {
data(tecator)
metric.DTW(tecator$absorp.fdata[1:4,])
ab=tecator[[1]]
D1=fda.usc:::DTW(ab$data[1,],ab$data[2,],p=2)
aa1=fda.usc:::findPath(D1$D)
D2=fda.usc:::DTW(ab$data[1,],ab$data[2,],p=2,w=5)
aa2=fda.usc:::findPath(D2$D)
D3=fda.usc:::WDTW(ab$data[1,],ab$data[2,],p=2,g=0.05) 
aa3=fda.usc:::findPath(D3$D)
D4=fda.usc:::TWED(ab$data[1,],ab$data[2,],p=2,lambda=0,nu=0)
aa4=fda.usc:::findPath(D4$D)
par(mfrow=c(2,2))
plot(c(ab[1:2]))
segments(ab$argvals[aa1[,1]],ab[1]$data[aa1[,1]],ab$argvals[aa1[,2]],ab[2]$data[aa1[,2]])
plot(c(ab[1:2]))
segments(ab$argvals[aa2[,1]],ab[1]$data[aa2[,1]],ab$argvals[aa2[,2]],ab[2]$data[aa2[,2]],col=2)
plot(c(ab[1:2]))
segments(ab$argvals[aa3[,1]],ab[1]$data[aa3[,1]],ab$argvals[aa3[,2]],ab[2]$data[aa3[,2]],col=3)
plot(c(ab[1:2]))
segments(ab$argvals[aa4[,1]],ab[1]$data[aa4[,1]],ab$argvals[aa4[,2]],ab[2]$data[aa4[,2]],col=4)
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace