cor_spearman: Spearman's correlation coefficient for multivariate...

Description Usage Arguments Details Value References See Also Examples

View source: R/correlation.R

Description

This function computes the Spearman's correlation coefficient for a multivariate functional dataset, with either a Modified Epigraph Index (MEI) or Modified Hypograph Index (MHI) ranking of univariate elements of data components.

Usage

1
cor_spearman(mfD, ordering = "MEI")

Arguments

mfD

a multivariate functional dataset whose Spearman's correlation coefficient must be computed, in form of multivariate mfData object.

ordering

the ordering relation to use on functional observations, either "MEI" for MEI or "MHI" for MHI (default is "MEI").

Details

Given a multivariate functional dataset, with first components X^1_1(t), X^1_2(t), …, X^1_N(t), second components X^2_1(t), X^2_2(t), …, X^2_N(t), etc., the function exploits either the MEI or MHI to compute the matrix of Spearman's correlation coefficients. Such matrix is symmetrical and has ones on the diagonal. The entry (i, j) represents the Spearman correlation coefficient between curves of component i and j.

See the references for more details.

Value

If the original dataset is bivariate, the function returns only the scalar value of the correlation coefficient for the two components. When the number of components is L >2, it returns the whole matrix of Spearman's correlation coefficients for all the components.

References

Valencia, D., Romo, J. and Lillo, R. (2015). Spearman coefficient for functions, Universidad Carlos III de Madrid technical report, http://EconPapers.repec.org/RePEc:cte:wsrepe:ws133329.

See Also

mfData, MEI, MHI

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
33
34
35
36
37
38
#### 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_spearman( mfD, ordering = 'MEI' )

# Correlation approx. zero (components were created independently)
cor_spearman( mfD, ordering = 'MHI' )

#### 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_spearman( mfD, ordering = 'MEI' )

# Correlation very high (components are nonlinearly dependent)
cor_spearman( mfD, ordering = 'MHI' )

roahd documentation built on Aug. 24, 2020, 9:07 a.m.