# Example usage:
library(MASS)
n = 50 # Sample Size
p = 5 # number of variables
rho = 0.4
# Building a Covariance structure with Autoregressive structure
cov_mat <- covMatAR(p = p, rho = rho)
# Simulated data
data <- mvrnorm(n = n, mu = rep(0,p), Sigma = cov_mat)
# Performing the test assuming that the population covariance matrix is unknown
indTest(data)
# Performing the test assuming that the population covariance matrix is known
indTest(data, covMat = cov_mat)
# Example for data with missing values
# Generating data with 10% of missing values
missing_rate <- 0.1
missing_index_row <- sample(1:n, size = round(n * missing_rate))
missing_index_col <- sample(1:p, size = 1)
data[missing_index_row, missing_index_col] <- NA # Introducing missing values
# Performing the test assuming that the population covariance matrix is unknown
indTest(data)
# Performing the test assuming that the population covariance matrix is known
indTest(data, covMat = cov_mat)
# Building a Covariance structure with Compound Symmetry structure
cov_mat <- covMatCS(p = p, rho = rho)
# Simulated data
data <- mvrnorm(n = n, mu = rep(0,p), Sigma = cov_mat)
# Performing the test assuming that the population covariance matrix is unknown
indTest(data)
# Performing the test assuming that the population covariance matrix is known
indTest(data, covMat = cov_mat)
# Building a Covariance structure with Circular structure
cov_mat <- covMatC(p = p, rho = rho)
# Simulated data
data <- mvrnorm(n = n, mu = rep(0,p), Sigma = cov_mat)
# Performing the test assuming that the population covariance matrix is unknown
indTest(data)
# Performing the test assuming that the population covariance matrix is known
indTest(data, covMat = cov_mat)
Run the code above in your browser using DataLab