R/correlation.R
cor_kendall.Rd
This function computes the Kendall's tau correlation coefficient for a bivariate functional dataset, with either a max or area-under-curve order order relation between univariate functional elements (components).
cor_kendall(mfD, ordering = "max")
a bivariate functional dataset whose Kendall's tau coefficient
must be computed, in form of bivariate mfData
object
(mfD$L=2
).
the ordering relation to use on functional observations,
either "max"
for the maximum relation or "area"
for the area
under the curve relation (default is "max"
).
The function returns the Kendall's tau correlation coefficient for
the bivariate dataset provided with mfData
.
Given a bivariate functional dataset, with first components \(X_1(t), X_2(t), \ldots, X_N(t)\) and second components \(Y_1(t), Y_2(t), \ldots, Y_N(t)\), the function exploits either the order relation based on the maxima or the area-under-curve relation to compare data and produce concordances and discordances, that are then used to compute the tau coefficient.
See the references for more details.
Valencia, D., Romo, J. and Lillo, R. (2015). A Kendall correlation
coefficient for functional dependence, Universidad Carlos III de Madrid
technical report,
http://EconPapers.repec.org/RePEc:cte:wsrepe:ws133228
.
#### TOTALLY INDEPENDENT COMPONENTS
N = 2e2
P = 1e3
grid = seq( 0, 1, length.out = P )
# Creating an exponential covariance function to simulate guassian data
Cov = exp_cov_function( grid, alpha = 0.3, beta = 0.4 )
# Simulating (independent) gaussian functional data with given center and
# covariance function
Data_1 = generate_gauss_fdata( N, centerline = sin( 2 * pi * grid ), Cov = Cov )
Data_2 = generate_gauss_fdata( N, centerline = sin( 2 * pi * grid ), Cov = Cov )
# Using the simulated data as (independent) components of a bivariate functional
# dataset
mfD = mfData( grid, list( Data_1, Data_2 ) )
# Correlation approx. zero (components were created independently)
cor_kendall( mfD, ordering = 'max' )
#> [1] -0.04251256
# Correlation approx. zero (components were created independently)
cor_kendall( mfD, ordering = 'area' )
#> [1] -0.004020101
#### TOTALLY DEPENDENT COMPONENTS
# Nonlinear transform of first component
Data_3 = t( apply( Data_1, 1, exp ) )
# Creating bivariate dataset starting from nonlinearly-dependent components
mfD = mfData( grid, list( Data_1, Data_3 ) )
# Correlation very high (components are nonlinearly dependent)
cor_kendall( mfD, ordering = 'max' )
#> [1] 1
# Correlation very high (components are nonlinearly dependent)
cor_kendall( mfD, ordering = 'area' )
#> [1] 0.9072362