Calculate the distance between functional objects over the defined range.
fdistmatrix(fd, subrange, distmethod)
fd | A functional data object |
---|---|
subrange | A vector of two values indicating the value range of functional object to calculate on. |
distmethod | The method for calculating the distance matrix. Choose
between |
A distance matrix with diagonal value and the upper half.
If choosing distmethod = "manual"
, the L2 distance between all pairs of
functions \(y_i(t)\) and \(y_j(t)\) is given by:
$$d_R(y_i, y_j) = \sqrt{\int_{a_r}^{b_r} [y_i(t) - y_j(t)]^2 dt}.$$
library(fda) # Examples taken from fda::Data2fd() data(gait) # Function only works on two dimensional data gait <- gait[, 1:5, 1] gaitbasis3 <- create.fourier.basis(nbasis = 5) gaitfd3 <- Data2fd(gait, basisobj = gaitbasis3)#> 'y' is missing, using 'argvals' #> 'argvals' is missing; using seq( 0 , 1 , length= 20 )#> boy1 boy2 boy3 boy4 boy5 #> boy1 0.000000 1.508725 2.702666 2.959672 6.555149 #> boy2 1.508725 0.000000 2.089777 3.740105 7.326595 #> boy3 2.702666 2.089777 0.000000 5.570693 9.180862 #> boy4 2.959672 3.740105 5.570693 0.000000 3.643998 #> boy5 6.555149 7.326595 9.180862 3.643998 0.000000