# funDist: Distance function In martinoandrea92/dpdistance: Inference and Clustering of Functional Data

## Description

This function allows you to compute the distance between two curves with the chosen metric.

## Usage

 `1` ```funDist(grid, x, y, metric, p = NULL, lambda = NULL, phi = NULL) ```

## Arguments

 `grid` the grid (of length `T`) over which the two curves are defined. `x` a vector containing the first curve. `y` a vector containing the second curve. `metric` the chosen distance to be used: `"L2"` for the classical L2-distance, `"trunc"` for the truncated Mahalanobis semi-distance, `"mahalanobis"` for the generalized Mahalanobis distance. `p` a positive numeric value containing the parameter of the regularizing function for the generalized Mahalanobis distance. `lambda` a vector containing the eigenvalues of the functional data from which `"x"` and `"y"` are extracted. `phi` a matrix containing the eigenfunctions of the functional data from which `"x"` and `"y"` are extracted.

## Value

The function returns a numeric value indicating the distance between the two curves.

## References

Ghiglietti A., Ieva F., Paganoni A. M. (2017). Statistical inference for stochastic processes: Two-sample hypothesis tests, Journal of Statistical Planning and Inference, 180:49-68.

Ghiglietti A., Paganoni A. M. (2017). Exact tests for the means of gaussian stochastic processes. Statics & Probability Letters, 131:102–107.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32``` ```# Define parameters: n <- 50 P <- 100 K <- 150 # Grid of the functional dataset t <- seq( 0, 1, length.out = P ) # Define the means and the parameters to use in the simulation # with the Karhunen - LoÃ¨ve expansion m1 <- t^2 * ( 1 - t ) lambda <- rep( 0, K ) theta <- matrix( 0, K, P ) for ( k in 1:K ) { lambda[k] <- 1 / ( k + 1 )^2 if ( k%%2 == 0 ) theta[k, ] <- sqrt( 2 ) * sin( k * pi * t ) else if ( k%%2 != 0 && k != 1 ) theta[k, ] <- sqrt( 2 ) * cos( ( k - 1 ) * pi * t ) else theta[k, ] <- rep( 1, P ) } # Simulate the functional data z <- simulate_KL( t, n, m1, rho = lambda, theta = theta ) # Extract two rows of the functional data x <- z\$data[[1]][1, ] y <- z\$data[[1]][2, ] d <- funDist( t, x, y, metric = "L2" ) ```

martinoandrea92/dpdistance documentation built on Nov. 18, 2017, 5:13 p.m.