Skip to contents

Given a covariance matrix \(S\) of \(p\) Gaussian variables, and a pre-specified group of variables \(P\), this function tests the null hypothesis of independence between the groups of variables in \(P\) and \(P^c\). Makes use of test_stat_CCA() and sample_psi().

Usage

classical_p_val(S, CP, k, n, mc_iter = 1000)

Arguments

S

a \(p \times p\) covariance matrix

CP

a vector of length \(p\) with \(i^{th}\) element denoting the group \(i^{th}\) variable belongs to

k

the group to be tested for independence with the remaining variables, i.e. \(P = [i : CP[i]==k]\)

n

sample size

mc_iter

the number of Monte Carlo iterations used to approximate the p-value; we recommend using a high value of this to obtain an approximation with high accuracy; default value is 1,000

Value

The p-value for the test of independence.

Examples

# Simulates a 10 x 3 X_1 from N(0, I)
set.seed(1)
X_1 <- matrix(rnorm(30), 10, 3)

# Simulates a 10 x 2 X_2 from N(0, I) independently of X_1
set.seed(2)
X_2 <- matrix(rnorm(20), 10, 2)

# Compute the covariance matrix of X = (X_1 X_2).
covX <- cov(cbind(X_1, X_2))
# tests for a difference in means between X_1 and X_2
classical_p_val(S=covX, CP=rep(1:2, times=c(3, 2)), k=1, n=10, mc_iter=100)
#> [1] 0.08