library(MASS)
set.seed(123)
# Create sample data with different correlation structures
S1 = diag(50) # Uncorrelated variables for group 1
S2 = diag(50)
S2[11:50, 11:50] = 0.3 # Some correlation in second block for group 2
S2 = (S2 + t(S2)) / 2 # Ensure symmetry
diag(S2) = 1
# Generate data for two groups
A = mvrnorm(30, mu = rep(0, 50), Sigma = S1)
B = mvrnorm(40, mu = rep(0, 50), Sigma = S2)
# Combine data and create group labels
combined_data1 = A[, 1:20]
combined_data2 = A[, 21:50]
combined_data1 = rbind(combined_data1, B[, 1:20])
combined_data2 = rbind(combined_data2, B[, 21:50])
groups = c(rep("GroupA", 30), rep("GroupB", 40))
# Perform RV comparison
result = RVcomparison(combined_data1, combined_data2,
group = groups, perm = 99)
print(result)
# Example with three groups for pairwise comparisons
C = mvrnorm(25, mu = rep(0, 50), Sigma = diag(50))
combined_data1_3grp = rbind(combined_data1, C[, 1:20])
combined_data2_3grp = rbind(combined_data2, C[, 21:50])
groups_3 = c(groups, rep("GroupC", 25))
result_3grp = RVcomparison(combined_data1_3grp, combined_data2_3grp,
group = groups_3, perm = 99)
print(result_3grp)
Run the code above in your browser using DataLab