BTestSpearman: Bootstrap Hypothesis Test on Spearman Correlation...

Description Usage Arguments Details Value See Also Examples

View source: R/bootstrap_spearman_inference.R

Description

This function performs a bootstrap test that checks whether the Spearman correlation structures (e.g. matrices) of two populations of compatible multivariate functional data are equal or not.

Usage

1
2
3
4
5
6
7
8
BTestSpearman(
  mfD1,
  mfD2,
  bootstrap_iterations = 1000,
  ordering = "MEI",
  normtype = "f",
  verbose = FALSE
)

Arguments

mfD1

is the first functional dataset, specified in form of mfData object; it must be compatible with mfD2.

mfD2

is the second functional dataset, specified in form of mfData object; it must be compatible with mfD1.

bootstrap_iterations

is the number of bootstrap iterations to be performed.

ordering

is the kind of ordering to be used in the computation of Spearman's correlation coefficient (default is MEI).

normtype

is the norm to be used when comparing the Spearman correlation matrices of the two functional datasets (default is Frobenius, allowed values are the same as for parameter type in the base function norm).

verbose

a boolean flag specifying whether to print the progress of bootstrap iterations or not (default is FALSE).

Details

Given a first multivariate functional population, X_1^(i), …, X_n^(i) with i=1, …, L, defined on the grid I = t_1, …, t_P, and a second multivariate functional population, Y_1^(i), …, Y_m^(i) with i=1, …, L, defined on the same grid I, the function performs a bootstrap test to check the hypothesis:

H_0: R_X = R_Y

H_1: R_X \neq R_Y,

where R_X and R_Y denote the L x L matrices of Spearman correlation coefficients of the two populations.

Value

The function returns the estimates of the test's p-value and statistics.

See Also

BCIntervalSpearman, BCIntervalSpearmanMultivariate, mfData

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
set.seed(1)

N  <- 200
P <- 100
L <- 2

grid <- seq(0, 1, length.out = P)

# Creating an exponential covariance function to simulate Gaussian data
Cov <- exp_cov_function(grid, alpha = 0.3, beta = 0.4)

# Simulating two populations of bivariate functional data
#
# The first population has very high correlation between first and second component
centerline_1 <- matrix(
  data = rep(sin(2 * pi * grid)),
  nrow = L,
  ncol = P,
  byrow = TRUE
)
values1 <- generate_gauss_mfdata(
  N = N,
  L = L,
  correlations = 0.9,
  centerline = centerline_1,
  listCov = list(Cov, Cov)
)
mfD1 <- mfData(grid, values1)

# Pointwise estimate
cor_spearman(mfD1)

# The second population has zero correlation between first and second component
centerline_2 <- matrix(
  data = rep(cos(2 * pi * grid)),
  nrow = L,
  ncol = P,
  byrow = TRUE
)
values2 <- generate_gauss_mfdata(
  N = N,
  L = L,
  correlations = 0,
  centerline = centerline_2,
  listCov = list(Cov, Cov)
)
mfD2 <- mfData(grid, values2)

# Pointwise estimate
cor_spearman(mfD2)

# Applying the test

BTestSpearman(mfD1, mfD2)

roahd documentation built on Nov. 4, 2021, 1:07 a.m.