# inst/mvParamConfig.R In BenBarnard/slidR: Heteroscedastic Linear Dimension Reduction

```# This is N and VZ's "Data.R" file with some cleanup.
library(pracma)

mvParamConfig <- function(situation){

# Set the dimension
p <- 10
# Define Unitary and Identity matrices
J <- matrix(1, nrow = p, ncol = p)
I <- diag(1, nrow = p, ncol = p)

###### 6.1 Rank(Sig2 - Sig1) = 1 and Unequal means  ###########################

if(situation == 1){

#Covariances
Sigma1 <- matrix(c(10, 4, 5, 4, 3, 4, 4, 5, 4, 3,
4, 10, 5, 2, 4, 3, 3, 5, 4, 3,
5, 5, 10, 5, 5, 3, 4, 4, 4, 4,
4, 2, 5, 10, 3, 4, 2, 3, 4, 3,
3, 4, 5, 3, 10, 3, 4, 5, 3, 3,
4, 3, 3, 4, 3, 12, 3, 4, 4, 4,
4, 3, 4, 2, 4, 3, 14, 2, 2, 2,
5, 5, 4, 3, 5, 4, 2, 12, -.5, -.5,
4, 4, 4, 4, 3, 4, 2, -.5, 14, -1,
3, 3, 4, 3, 3, 4, 2, -.5, -1, 11),
nrow=10, ncol=10)

Sigma2 <- Sigma1 + 6
Sigma2[8:10,8:10] <- Sigma2[8:10, (8:10)] + 4
Sigma3 <- NULL

# Unequal Means
mu1 <- rep(0, p)
mu2 <- rep(10, p)
mu3 <- NULL

}

###### 6.2 Rank(Sig2 - Sig1) = 1 and Relatively Close Means  ##################

if(situation == 2){

# Covariances
Sigma1 <- matrix(c(10, 4, 5, 4, 3, 4, 4, 5, 4, 3,
4, 10, 5, 2, 4, 3, 3, 5, 4, 3,
5, 5, 10, 5, 5, 3, 4, 4, 4, 4,
4, 2, 5, 10, 3, 4, 2, 3, 4, 3,
3, 4, 5, 3, 12, 3, 4, 5, 3, 3,
4, 3, 3, 4, 3, 9, 3, 4, 4, 4,
4, 3, 4, 2, 4, 3, 14, 2, 2, 2,
5, 5, 4, 3, 5, 4, 2, 12, 1, -.5,
4, 4, 4, 4, 3, 4, 2, 1, 14, -1,
3, 3, 4, 3, 3, 4, 2, -.5, -1, 11),
nrow=10, ncol=10)

# Sigma2 is created such that rank(Sigma2 - Sigma1) = 1
Sigma2 <- Sigma1 - 2
Sigma2[,4] <- Sigma1[,4]
Sigma2[4,] <- Sigma1[4,]
Sigma3 <- NULL

# Means
mu1  <- rep(0, p)
mu2  <- rep(2, p)
mu3  <- NULL

}

###### 6.3 Rank(Sig2 - Sig1) = 1 and Relatively Close Means  ##################

if(situation == 3){

# Covariances using the inter-class covariance structure:
Sigma1 <- I + J
Sigma2 <- 1.5 * I + 0.5 * J
Sigma3 <- NULL

# Means
mu1 <- rep(0, p)
mu2 <- c(0, 2, rep(0, 8))
mu3 <-NULL

}

###### 6.4 Unequal means, Unequal Covariances, m = 3  #########################

if(situation == 4){

# Covariances:
Sigma1 <- I
Sigma2 <- I + J
Sigma3 <- Sigma2
Sigma3[3,] <- rep(0, 10)
Sigma3[,3] <- c(0, 0, 10, rep(0, 7))

# Means:
mu1 <- rep(0, p)
mu2 <- rep(1, p)
mu3 <- rep(2, p)

}

###### 6.5 Means Differ in the first p-1, elliptical Covariance ###############

if(situation == 5){

# Covariances (same as situation 2)
Sigma1 <- matrix(c(10, 4, 5, 4, 3, 4, 4, 5, 4, 3,
4, 10, 5, 2, 4, 3, 3, 5, 4, 3,
5, 5, 10, 5, 5, 3, 4, 4, 4, 4,
4, 2, 5, 10, 3, 4, 2, 3, 4, 3,
3, 4, 5, 3, 12, 3, 4, 5, 3, 3,
4, 3, 3, 4, 3, 9, 3, 4, 4, 4,
4, 3, 4, 2, 4, 3, 14, 2, 2, 2,
5, 5, 4, 3, 5, 4, 2, 12, 1, -.5,
4, 4, 4, 4, 3, 4, 2, 1, 14, -1,
3, 3, 4, 3, 3, 4, 2, -.5, -1, 11),
nrow=10, ncol=10)

Sigma1 <- Sigma1 / 5

# Inflate the variance of the first two dimensions
Sigma2 <- Sigma1
Sigma2[1,1] <- 20
Sigma2[2,2] <- 40
Sigma3 <- Sigma1
Sigma3[1,1] <- 35
Sigma3[2,2] <- 40

# Means:
mu1 <- rep(0, p)
mu2 <- rep(c(1,0), 5)
mu3 <- c(rep(-1, 9),0)

}

###### 6.6 Unequal highly elliptical covariance and unequal means #############

if(situation == 6){

prac <- matrix(rnorm(p * p, 0, p), p, p)
Q <- pracma::gramSchmidt(prac)\$Q

j <- seq(1, p, 1)

# Eigenvalues for each population
eigen.v1 <- (p - 1) * ((p - 1) * (j - 1) / (p - 1) + 1) ^ 2
eigen.v2 <- ((p - 1) * (j - 1) / (p - 1) + 1) ^ 2
eigen.v3 <- ((p - 1) * (j - (p - 1) / 2) / (p - 1)) ^ 2

# Covariance Matrices
Sigma1 <- Q %*% diag(eigen.v3) %*% t(Q) + diag(c(10, 20), 10)
Sigma2 <- Sigma1 + 30
Sigma3 <- Sigma1 + 60

mu1 <- rep(0, p)
mu2 <- rep(14 / sqrt(p), p)
mu3 <- rep(8,10)

}

###### 6.7 Bootstrap Samples ##################################################

if(situation == 7){
# NOTE: I do not have this file. This errors.

#     #View(spectf)
#     #spectf <- as.matrix(spectf)
#     ### Selecting 10 variables from data set:
#     #vars2 = c(2, 4, 12, 19, 23, 28, 29, 32, 34, 38)
#     vars2 = c(29, 19, 32, 12, 15, 4, 34, 22, 23, 39)
#     # Finding means and covariance matrices of the two groups:
#     spec1 = spectf[spectf\$V1 == 1, vars2]
#     spec2 = spectf[spectf\$V1 == 0, vars2]
#
#     # Covariances
#     Sigma1 <- round(cov(spec1), 3)
#     Sigma2 <- round(cov(spec2), 3)
#     Sigma3 <- NULL
#
#     # Means
#     mu1 <- round(as.matrix(apply(spec1, 2, mean)), 1)
#     mu2 <- round(as.matrix(apply(spec2, 2, mean)), 1)
#     mu3 <- NULL
Sigma1 <- Sigma2 <- Sigma3 <- NULL
mu1 <- mu2 <- mu3 <- NULL

}

###### New Situation 1 ########################################################

if(situation == 8){

Sigma1 <- I
Sigma2 <- diag(c(10, 0.1, rep(0.0001, 8)), nrow = p, ncol = p)
Sigma3 <- 10 * Sigma2

# Unequal Means:
mu1 <- rep(0, p)
mu2 <- rep(1, p)
mu3 <- c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0)

}

###### New Situation 2 ########################################################

if(situation == 9){

Sigma1 <- matrix(c(20,1,3,3,3,3,3,3,3,3,
1,5,3,3,3,3,3,3,3,3,
3,3,5,4,4,4,4,4,4,4,
3,3,4,5,4,4,4,4,4,4,
3,3,4,4,5,4,4,4,4,4,
3,3,4,4,4,5,4,4,4,4,
3,3,4,4,4,4,5,4,4,4,
3,3,4,4,4,4,4,5,4,4,
3,3,4,4,4,4,4,4,5,4,
3,3,4,4,4,4,4,4,4,5),
nrow=10, ncol=10)

Sigma2 <- matrix(c(10.30, 1.30, 2.95, 2.95, 2.95, 2.95, 2.95, 2.95, 2.95, 2.95,
1.30, 6.45, 2.84, 2.84, 2.84, 2.84, 2.84, 2.84, 2.84, 2.84,
2.95, 2.84, 4.16, 4.15, 4.15, 4.15, 4.15, 4.15, 4.15, 4.15,
2.95, 2.84, 4.15, 4.16, 4.15, 4.15, 4.15, 4.15, 4.15, 4.15,
2.95, 2.84, 4.15, 4.15, 4.16, 4.15, 4.15, 4.15, 4.15, 4.15,
2.95, 2.84, 4.15, 4.15, 4.15, 4.16, 4.15, 4.15, 4.15, 4.15,
2.95, 2.84, 4.15, 4.15, 4.15, 4.15, 4.16, 4.15, 4.15, 4.15,
2.95, 2.84, 4.15, 4.15, 4.15, 4.15, 4.15, 4.16, 4.15, 4.15,
2.95, 2.84, 4.15, 4.15, 4.15, 4.15, 4.15, 4.15, 4.16, 4.15,
2.95, 2.84, 4.15, 4.15, 4.15, 4.15, 4.15, 4.15, 4.15, 4.16),
nrow=10, ncol=10)

Sigma3 <- matrix(c( 1.87, 0.99, 0.94, 0.94, 0.94, 0.94, 0.94, 0.94, 0.94, 0.94,
0.99, 1.02, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01,
0.94, 1.01, 1.02, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01,
0.94, 1.01, 1.01, 1.02, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01,
0.94, 1.01, 1.01, 1.01, 1.02, 1.01, 1.01, 1.01, 1.01, 1.01,
0.94, 1.01, 1.01, 1.01, 1.01, 1.02, 1.01, 1.01, 1.01, 1.01,
0.94, 1.01, 1.01, 1.01, 1.01, 1.01, 1.02, 1.01, 1.01, 1.01,
0.94, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.02, 1.01, 1.01,
0.94, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.02, 1.01,
0.94, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.01, 1.02),
nrow=10, ncol=10)
# Rank 3 difference between 2 and 3
# Means:
mu1 <- rep(1, p)
mu2 <- rep(3, p)
mu3 <- rep(c(-1,1),5)

}

###### New Situation 3 ########################################################

if(situation==10){

Sigma1 <- matrix(c(19.83, 1.11, 3.16, 3.16, 3.16, 3.16, 3.16, 3.16, 3.16, 3.16,
1.11, 4.57, 3.11, 3.11, 3.11, 3.11, 3.11, 3.11, 3.11, 3.11,
3.16, 3.11, 4.25, 4.10, 4.15, 4.19, 4.28, 4.32, 4.09, 4.22,
3.16, 3.11, 4.10, 5.40, 4.36, 4.09, 4.17, 3.82, 4.32, 4.24,
3.16, 3.11, 4.15, 4.36, 4.55, 4.41, 4.19, 3.91, 3.97, 4.07,
3.16, 3.11, 4.19, 4.09, 4.41, 4.71, 3.95, 4.30, 4.09, 3.87,
3.16, 3.11, 4.28, 4.17, 4.19, 3.95, 4.58, 4.18, 3.85, 4.41,
3.16, 3.11, 4.32, 3.82, 3.91, 4.30, 4.18, 4.71, 4.19, 4.17,
3.16, 3.11, 4.09, 4.32, 3.97, 4.09, 3.85, 4.19, 4.89, 4.21,
3.16, 3.11, 4.22, 4.24, 4.07, 3.87, 4.41, 4.17, 4.21, 5.42),
nrow=10, ncol=10)
Sigma1 <- round(Sigma1)

Sigma2 <- matrix(c(16.47, 4.31, 6.65, 6.65, 6.65, 6.65, 6.65, 6.65, 6.65, 6.65,
4.31, 4.43, 4.45, 4.45, 4.45, 4.45, 4.45, 4.45, 4.45, 4.45,
6.65, 4.45, 6.04, 5.95, 5.96, 5.98, 6.06, 6.09, 5.97, 6.04,
6.65, 4.45, 5.95, 6.18, 6.14, 6.01, 5.98, 5.79, 6.05, 6.00,
6.65, 4.45, 5.96, 6.14, 6.34, 6.27, 5.94, 5.78, 5.83, 5.84,
6.65, 4.45, 5.98, 6.01, 6.27, 6.42, 5.82, 5.97, 5.89, 5.75,
6.65, 4.45, 6.06, 5.98, 5.94, 5.82, 6.23, 6.04, 5.87, 6.16,
6.65, 4.45, 6.09, 5.79, 5.78, 5.97, 6.04, 6.32, 6.04, 6.06,
6.65, 4.45, 5.97, 6.05, 5.83, 5.89, 5.87, 6.04, 6.38, 6.06,
6.65, 4.45, 6.04, 6.00, 5.84, 5.75, 6.16, 6.06, 6.06, 6.19),
nrow=10, ncol=10)
Sigma2 <- Sigma2 + diag(1,10)

# Create the rank 2 difference matrix
difference <- diag(0, nrow = 10)
difference[1,1] <- difference[2,2] <- 1

# NOT POSITIVE DEFINITE
#     Sigma3 <- matrix(c(25.00, -4.31, 6.65, 6.65, 6.65, 6.65, 6.65, 6.65, 6.65, 6.65,
#                        -4.31, 15.00, 4.45, 4.45, 4.45, 4.45, 4.45, 4.45, 4.45, 4.45,
#                         6.65,  4.45, 6.04, 5.95, 5.96, 5.98, 6.06, 6.09, 5.97, 6.04,
#                         6.65,  4.45, 5.95, 6.18, 6.14, 6.01, 5.98, 5.79, 6.05, 6.00,
#                         6.65,  4.45, 5.96, 6.14, 6.34, 6.27, 5.94, 5.78, 5.83, 5.84,
#                         6.65,  4.45, 5.98, 6.01, 6.27, 6.42, 5.82, 5.97, 5.89, 5.75,
#                         6.65,  4.45, 6.06, 5.98, 5.94, 5.82, 6.23, 6.04, 5.87, 6.16,
#                         6.65,  4.45, 6.09, 5.79, 5.78, 5.97, 6.04, 6.32, 6.04, 6.06,
#                         6.65,  4.45, 5.97, 6.05, 5.83, 5.89, 5.87, 6.04, 6.38, 6.06,
#                         6.65,  4.45, 6.04, 6.00, 5.84, 5.75, 6.16, 6.06, 6.06, 6.19),
#                       nrow=10, ncol=10)

Sigma3 <- Sigma2 + difference
# Rank of Sigma2 - Sigma3 = 2

# Means:
mu1 <- c(-1,-1, rep(0, 8))
mu2 <- rep(0, 10)
mu3 <- c(2,2,rep(0, 8))

}

###### New Situation 4 ########################################################

if(situation==11){

Sigma1 <- matrix(c(6,1,3,3,3,3,3,3,3,3,
1,6,3,3,3,3,3,3,3,3,
3,3,4,3,3,3,3,3,3,3,
3,3,3,4,3,3,3,3,3,3,
3,3,3,3,4,3,3,3,3,3,
3,3,3,3,3,4,3,3,3,3,
3,3,3,3,3,3,4,3,3,3,
3,3,3,3,3,3,3,4,3,3,
3,3,3,3,3,3,3,3,4,3,
3,3,3,3,3,3,3,3,3,4),
nrow=10, ncol=10)

Sigma2 <- matrix(c(10, 1,3,3,3,3,3,3,3,3,
1,10,3,3,3,3,3,3,3,3,
3, 3,4,3,3,3,3,3,3,3,
3, 3,3,4,3,3,3,3,3,3,
3, 3,3,3,4,3,3,3,3,3,
3, 3,3,3,3,4,3,3,3,3,
3, 3,3,3,3,3,4,3,3,3,
3, 3,3,3,3,3,3,4,3,3,
3, 3,3,3,3,3,3,3,4,3,
3, 3,3,3,3,3,3,3,3,4),
nrow=10, ncol=10)

Sigma3 <- matrix(c(10, 1,3,3,3,3,3,3,3,3,
1,10,3,3,3,3,3,3,3,3,
3, 3,4,3,3,3,3,3,3,3,
3, 3,3,4,3,3,3,3,3,3,
3, 3,3,3,4,3,3,3,3,3,
3, 3,3,3,3,4,3,3,3,3,
3, 3,3,3,3,3,4,3,3,3,
3, 3,3,3,3,3,3,4,3,3,
3, 3,3,3,3,3,3,3,4,3,
3, 3,3,3,3,3,3,3,3,4),
nrow=10, ncol=10)

# Means
mu1 <- rep(0,10)
mu2 <- rep(3,10)
mu3 <- rep(7,10)

}

###### New Situation 5 ########################################################

if(situation==12){

# Create Covariances such that their differences are all rank 3 and 4. 1 - 2
# will have rank 3, while 1 - 3 and 2 - 3 will have rank 4.

Sigma3 <- matrix(c(7,2,3,3,3,3,3,3,3,3,
2,7,3,3,3,3,3,3,3,3,
3,3,4,3,3,3,3,3,3,3,
3,3,3,5,3,3,3,3,3,3,
3,3,3,3,5,3,3,3,3,3,
3,3,3,3,3,5,3,3,3,3,
3,3,3,3,3,3,5,3,3,3,
3,3,3,3,3,3,3,5,3,3,
3,3,3,3,3,3,3,3,5,3,
3,3,3,3,3,3,3,3,3,5),
nrow=10, ncol=10)
Sigma3 <- Sigma3 + 3 * J

Sigma2 <- Sigma3 - diag(c(rep(1,4),rep(0,6)))
Sigma1 <- Sigma2 + diag(c(rep(2,3),rep(0,7)))

#     Sigma1 <- matrix(c(16,-3,-3,3,3,3,3,3,3,3,
#                        -3,16,-3,3,3,3,3,3,3,3,
#                        -3,-3, 4,3,3,3,3,3,3,3,
#                         3, 3, 3,5,3,3,3,3,3,3,
#                         3, 3, 3,3,5,3,3,3,3,3,
#                         3, 3, 3,3,3,5,3,3,3,3,
#                         3, 3, 3,3,3,3,5,3,3,3,
#                         3, 3, 3,3,3,3,3,5,3,3,
#                         3, 3, 3,3,3,3,3,3,5,3,
#                         3, 3, 3,3,3,3,3,3,3,5),
#                       nrow=10, ncol=10)
#     Sigma1 <- Sigma1 + diag(4,10)

# NOT POSITIVE DEFINITE
#     Sigma2 <- matrix(c(9,4,5,3,3,3,3,3,3,3,
#                        4,9,6,3,3,3,3,3,3,3,
#                        5,6,4,3,3,3,3,3,3,3,
#                        3,3,3,5,3,3,3,3,3,3,
#                        3,3,3,3,5,3,3,3,3,3,
#                        3,3,3,3,3,5,3,3,3,3,
#                        3,3,3,3,3,3,5,3,3,3,
#                        3,3,3,3,3,3,3,5,3,3,
#                        3,3,3,3,3,3,3,3,5,3,
#                        3,3,3,3,3,3,3,3,3,5),
#                       nrow=10, ncol=10)

# Mean
mu1 <- c(rep(0,5), rep(3,5))
mu2 <- c(rep(3,5), rep(0,5))
mu3 <- rep(7,10)

}

###### New Situation 6 ########################################################

if(situation==13){

Sigma1 <- matrix(c(5.30, -0.01, -0.37, -1.69,  0.08,  0.92, -0.55, 0.00,  0.63,  0.28,
-0.01,  8.11,  0.00, -0.01,  0.00,  0.00,  0.00, 0.00,  0.00,  0.00,
-0.37,  0.00,  8.02, -0.30, -0.14, -0.04, -0.09, 0.00, -0.08,  0.00,
-1.69, -0.01, -0.30,  8.35, -0.63, -0.31, -0.34, 0.00, -0.48, -0.03,
0.08,  0.00, -0.14, -0.63,  5.20,  0.39, -0.21, 0.00,  0.28,  0.12,
0.92,  0.00, -0.04, -0.31,  0.39,  3.93, -0.10, 0.00,  0.60,  0.17,
-0.55,  0.00, -0.09, -0.34, -0.21, -0.10,  9.56, 0.00, -0.16, -0.01,
0.00,  0.00,  0.00,  0.00,  0.00,  0.00,  0.00, 2.52,  0.00,  0.00,
0.63,  0.00, -0.08, -0.48,  0.28,  0.60, -0.16, 0.00,  4.60,  0.16,                        0.28,  0.00,  0.00, -0.03,  0.12,  0.17, -0.01, 0.00,  0.16,  2.29),
nrow=10,ncol=10)

Sigma2 <- matrix(c(7.86,  2.55,  2.19,  0.87, 2.64, 3.48,  2.01, 2.56, 3.19,  2.84,
2.55, 10.67,  2.56,  2.55, 2.56, 2.56,  2.56, 2.56, 2.56,  2.56,
2.19,  2.56, 10.58,  2.26, 2.42, 2.52,  2.47, 2.56, 2.48,  2.56,
0.87,  2.55,  2.26, 10.91, 1.93, 2.25,  2.22, 2.56, 2.08,  2.53,
2.64,  2.56,  2.42,  1.93, 7.76, 2.95,  2.35, 2.56, 2.84,  2.68,
3.48,  2.56,  2.52,  2.25, 2.95, 6.49,  2.46, 2.56, 3.16,  2.73,
2.01,  2.56,  2.47,  2.22, 2.35, 2.46, 12.12, 2.56, 2.40,  2.55,
2.56,  2.56,  2.56,  2.56, 2.56, 2.56,  2.56, 5.08, 2.56,  2.56,
3.19,  2.56,  2.48,  2.08, 2.84, 3.16,  2.40, 2.56, 7.16,  2.72,
2.84,  2.56,  2.56,  2.53, 2.68, 2.73,  2.55, 2.56, 2.72,  4.85),
nrow=10, ncol=10)

Sigma3 <- matrix(c(8.36,  2.55,  2.19, 0.87, 2.64, 3.47,  2.01, 2.56, 3.19,  2.84,
2.55, 11.13,  2.56, 2.55, 2.56, 2.56,  2.56, 2.56, 2.56,  2.56,
2.19,  2.56, 10.48, 2.26, 2.42, 2.52,  2.47, 2.56, 2.48,  2.56,
0.87,  2.55,  2.26, 9.70, 1.93, 2.25,  2.22, 2.56, 2.08,  2.53,
2.64,  2.56,  2.42, 1.93, 7.72, 2.94,  2.35, 2.56, 2.84,  2.68,
3.47,  2.56,  2.52, 2.25, 2.94, 3.67,  2.46, 2.56, 3.15,  2.73,
2.01,  2.56,  2.47, 2.22, 2.35, 2.46, 11.21, 2.56, 2.40,  2.55,
2.56,  2.56,  2.56, 2.56, 2.56, 2.56,  2.56, 6.75, 2.56,  2.56,
3.19,  2.56,  2.48, 2.08, 2.84, 3.15,  2.40, 2.56, 9.81,  2.72,
2.84,  2.56,  2.56, 2.53, 2.68, 2.73,  2.55, 2.56, 2.72, 10.75),
nrow=10, ncol=10)

# Means
mu1 <- c(rep(c(-1,0),5))
mu2 <- c(3.27,4.19,3.36,6.78,2.46,3.27,4.19,3.36,6.78,2.46)
mu3 <- c(1.21,7.40,8.54,7.61,5.91,8.12,4.77,7.34,9.27,8.99)

}

###### New Situation 7 ########################################################

if(situation==14){

Sigma1 <- matrix(c(3.53, 2.36, 2.00, 0.73, 2.05, 1.76, 1.60, 1.69, 2.91, 2.74,
2.36, 5.21, 2.75, 2.20, 2.42, 2.10, 3.06, 2.30, 3.03, 3.09,
2.00, 2.75, 4.35, 1.82, 2.10, 1.83, 2.58, 2.01, 2.66, 2.68,
0.73, 2.20, 1.82, 3.18, 1.23, 1.10, 2.27, 1.38, 1.29, 2.06,
2.05, 2.42, 2.10, 1.23, 2.88, 1.62, 2.00, 1.68, 2.51, 2.59,
1.76, 2.10, 1.83, 1.10, 1.62, 2.40, 1.76, 1.46, 2.16, 2.25,
1.60, 3.06, 2.58, 2.27, 2.00, 1.76, 5.30, 2.07, 2.32, 2.70,
1.69, 2.30, 2.01, 1.38, 1.68, 1.46, 2.07, 2.56, 2.16, 2.35,
2.91, 3.03, 2.66, 1.29, 2.51, 2.16, 2.32, 2.16, 4.45, 3.43,
2.74, 3.09, 2.68, 2.06, 2.59, 2.25, 2.70, 2.35, 3.43, 5.13),
nrow=10, ncol=10)

Sigma2 <- matrix(c(3.84, 2.67, 2.31, 1.04, 2.36, 2.07, 1.91, 2.00, 3.22,  3.05,
2.67, 5.52, 3.06, 2.51, 2.73, 2.41, 3.37, 2.61, 3.34,  3.40,
2.31, 3.06, 4.66, 2.13, 2.41, 2.14, 2.89, 2.32, 2.97,  2.99,
1.04, 2.51, 2.13, 3.49, 1.54, 1.41, 2.58, 1.69, 1.60,  2.37,
2.36, 2.73, 2.41, 1.54, 3.19, 1.93, 2.31, 1.99, 2.82,  2.90,
2.07, 2.41, 2.14, 1.41, 1.93, 2.71, 2.07, 1.77, 2.47,  2.56,
1.91, 3.37, 2.89, 2.58, 2.31, 2.07, 5.61, 2.38, 2.63,  3.01,
2.00, 2.61, 2.32, 1.69, 1.99, 1.77, 2.38, 2.87, 2.47,  2.66,
3.22, 3.34, 2.97, 1.60, 2.82, 2.47, 2.63, 2.47, 4.76,  3.74,
3.05, 3.40, 2.99, 2.37, 2.90, 2.56, 3.01, 2.66, 3.74,  5.44),
nrow=10, ncol=10)

Sigma3 <- matrix(c(4.98, 2.81, 2.45, 1.18, 2.50, 2.21, 2.05, 2.14, 3.36,  3.19,
2.81, 7.66, 3.20, 2.65, 2.87, 2.55, 3.51, 2.75, 3.48,  3.54,
2.45, 3.20, 4.80, 2.27, 2.55, 2.28, 3.03, 2.46, 3.11,  3.13,
1.18, 2.65, 2.27, 3.63, 1.68, 1.55, 2.72, 1.83, 1.74,  2.51,
2.50, 2.87, 2.55, 1.68, 3.33, 2.07, 2.45, 2.13, 2.96,  3.04,
2.21, 2.55, 2.28, 1.55, 2.07, 2.85, 2.21, 1.91, 2.61,  2.70,
2.05, 3.51, 3.03, 2.72, 2.45, 2.21, 5.75, 2.52, 2.77,  3.15,
2.14, 2.75, 2.46, 1.83, 2.13, 1.91, 2.52, 3.01, 2.61,  2.80,
3.36, 3.48, 3.11, 1.74, 2.96, 2.61, 2.77, 2.61, 4.90,  3.88,
3.19, 3.54, 3.13, 2.51, 3.04, 2.70, 3.15, 2.80, 3.88,  5.58),
nrow=10, ncol=10)

# Means
mu1 <- c(rep(0,5), rep(3,5))
mu2 <- c(rep(4,3), rep(1,7))
mu3 <- c(rep(8,4), rep(2,6))

}

###### New Situation 8 ########################################################

if(situation==15){

Sigma1 <- matrix(c(6.78, 3.61, 3.25, 1.98, 3.30, 3.01, 2.85, 2.94, 4.16,  3.99,
3.61, 8.46, 4.00, 3.45, 3.67, 3.35, 4.31, 3.55, 4.28,  4.34,
3.25, 4.00, 7.60, 3.07, 3.35, 3.08, 3.83, 3.26, 3.91,  3.93,
1.98, 3.45, 3.07, 6.43, 2.48, 2.35, 3.52, 2.63, 2.54,  3.31,
3.30, 3.67, 3.35, 2.48, 6.13, 2.87, 3.25, 2.93, 3.76,  3.84,
3.01, 3.35, 3.08, 2.35, 2.87, 3.65, 3.01, 2.71, 3.41,  3.50,
2.85, 4.31, 3.83, 3.52, 3.25, 3.01, 6.55, 3.32, 3.57,  3.95,
2.94, 3.55, 3.26, 2.63, 2.93, 2.71, 3.32, 3.81, 3.41,  3.60,
4.16, 4.28, 3.91, 2.54, 3.76, 3.41, 3.57, 3.41, 5.70,  4.68,
3.99, 4.34, 3.93, 3.31, 3.84, 3.50, 3.95, 3.60, 4.68,  6.38),
nrow=10, ncol=10)

Sigma2 <- matrix(c(11.03,  7.86,  7.50,  6.23,  7.55, 3.01, 2.85, 2.94, 4.16,  3.99,
7.86, 12.71,  8.25,  7.70,  7.92, 3.35, 4.31, 3.55, 4.28,  4.34,
7.50,  8.25, 11.85,  7.32,  7.60, 3.08, 3.83, 3.26, 3.91,  3.93,
6.23,  7.70,  7.32, 10.68,  6.73, 2.35, 3.52, 2.63, 2.54,  3.31,
7.55,  7.92,  7.60,  6.73, 10.38, 2.87, 3.25, 2.93, 3.76,  3.84,
3.01,  3.35,  3.08,  2.35,  2.87, 3.65, 3.01, 2.71, 3.41,  3.50,
2.85,  4.31,  3.83,  3.52,  3.25, 3.01, 6.55, 3.32, 3.57,  3.95,
2.94,  3.55,  3.26,  2.63,  2.93, 2.71, 3.32, 3.81, 3.41,  3.60,
4.16,  4.28,  3.91,  2.54,  3.76, 3.41, 3.57, 3.41, 5.70,  4.68,
3.99,  4.34,  3.93,  3.31,  3.84, 3.50, 3.95, 3.60, 4.68,  6.38),
nrow=10, ncol=10)

Sigma3 <- 0.56 * Sigma2 + 0.44 * Sigma1

# Means
mu1 <- c(rep(10,5), rep(3,5))
mu2 <- c(rep(4,3), rep(8,7))
mu3 <- c(rep(12,4), rep(5,6))

}

###### Gabriel Situation 1 ##################################################

if(situation == 16){
# Nearly identical first and second covariances. Third covariance has decaying
# correlation and constant variance.

#Covariances
Sigma1 <- matrix(c(10, 4, 5, 4, 3, 4, 4, 5, 4, 3,
4, 10, 5, 2, 4, 3, 3, 5, 4, 3,
5, 5, 10, 5, 5, 3, 4, 4, 4, 4,
4, 2, 5, 10, 3, 4, 2, 3, 4, 3,
3, 4, 5, 3, 10, 3, 4, 5, 3, 3,
4, 3, 3, 4, 3, 12, 3, 4, 4, 4,
4, 3, 4, 2, 4, 3, 14, 2, 2, 2,
5, 5, 4, 3, 5, 4, 2, 12, -.5, -.5,
4, 4, 4, 4, 3, 4, 2, -.5, 14, -1,
3, 3, 4, 3, 3, 4, 2, -.5, -1, 11),
nrow=10, ncol=10)

Sigma2 <- Sigma1 + 6
Sigma2[8:10,8:10] <- Sigma2[8:10, (8:10)] + 4

x <- 25 ^ (1 / 1:10)

Sigma3 <- diag(sqrt(1.25), nrow = 10) %*%
toeplitz(x / 25) %*%
diag(sqrt(1.25), nrow = 10)

# Means
mu1 <- rep(-2,10)
mu2 <- rep(2,10)
mu3 <- rep(0,10)

}

###### Gabriel Situation 2 ##################################################
# Unequal Means and Covariances
if(situation == 17){
prac <- matrix(rnorm(p * p, 0, p), p, p)
Q <- pracma::gramSchmidt(prac)\$Q

j <- seq(1, p, 1)

# Eigenvalues for each population
eigen.v1 <- (p - 1) * ((p - 1) * (j - 1) / (p - 1) + 1) ^ 2
eigen.v2 <- ((p - 1) * (j - 1) / (p - 1) + 1) ^ 2
eigen.v3 <- ((p - 1) * (j - (p - 1) / 2) / (p - 1)) ^ 2

# Covariance Matrices
Sigma1 <- Q %*% diag(eigen.v3) %*% t(Q) + diag(c(10, 20), 10)
Sigma2 <- Sigma1 + 25
Sigma3 <- Sigma1 + 50

mu1 <- rep(0, p)
mu2 <- rep(10 / sqrt(p), p)
mu3 <- rep(10, p)

}

###### Gabriel Situation 3 ##################################################
# Unequal Means and Covariances
if(situation == 18){
Sigma1 <- matrix(c(6.78, 3.61, 3.25, 1.98, 3.30, 3.01, 2.85, 2.94, 4.16,  3.99,
3.61, 8.46, 4.00, 3.45, 3.67, 3.35, 4.31, 3.55, 4.28,  4.34,
3.25, 4.00, 7.60, 3.07, 3.35, 3.08, 3.83, 3.26, 3.91,  3.93,
1.98, 3.45, 3.07, 6.43, 2.48, 2.35, 3.52, 2.63, 2.54,  3.31,
3.30, 3.67, 3.35, 2.48, 6.13, 2.87, 3.25, 2.93, 3.76,  3.84,
3.01, 3.35, 3.08, 2.35, 2.87, 3.65, 3.01, 2.71, 3.41,  3.50,
2.85, 4.31, 3.83, 3.52, 3.25, 3.01, 6.55, 3.32, 3.57,  3.95,
2.94, 3.55, 3.26, 2.63, 2.93, 2.71, 3.32, 3.81, 3.41,  3.60,
4.16, 4.28, 3.91, 2.54, 3.76, 3.41, 3.57, 3.41, 5.70,  4.68,
3.99, 4.34, 3.93, 3.31, 3.84, 3.50, 3.95, 3.60, 4.68,  6.38),
nrow=10, ncol=10)

Sigma2 <- matrix(c(11.03,  7.86,  7.50,  6.23,  7.55, 3.01, 2.85, 2.94, 4.16,  3.99,
7.86, 12.71,  8.25,  7.70,  7.92, 3.35, 4.31, 3.55, 4.28,  4.34,
7.50,  8.25, 11.85,  7.32,  7.60, 3.08, 3.83, 3.26, 3.91,  3.93,
6.23,  7.70,  7.32, 10.68,  6.73, 2.35, 3.52, 2.63, 2.54,  3.31,
7.55,  7.92,  7.60,  6.73, 10.38, 2.87, 3.25, 2.93, 3.76,  3.84,
3.01,  3.35,  3.08,  2.35,  2.87, 3.65, 3.01, 2.71, 3.41,  3.50,
2.85,  4.31,  3.83,  3.52,  3.25, 3.01, 6.55, 3.32, 3.57,  3.95,
2.94,  3.55,  3.26,  2.63,  2.93, 2.71, 3.32, 3.81, 3.41,  3.60,
4.16,  4.28,  3.91,  2.54,  3.76, 3.41, 3.57, 3.41, 5.70,  4.68,
3.99,  4.34,  3.93,  3.31,  3.84, 3.50, 3.95, 3.60, 4.68,  6.38),
nrow=10, ncol=10)

Sigma3 <- 0.56 * Sigma2 + 0.44 * Sigma1

# Means
mu1 <- c(rep(10,5), rep(3,5))
mu2 <- c(rep(4,5), rep(11,5))
mu3 <- c(rep(12,5), rep(5,5))

}

###### Return Statements ####################################################

if(is.null(mu3)){
return(list(Mu = list(mu1 = mu1, mu2 = mu2),
Sigma = list(Sigma1 = Sigma1, Sigma2 = Sigma2)))
}

return(list(Mu = list(mu1 = mu1, mu2 = mu2, mu3 = mu3),
Sigma = list(Sigma1 = Sigma1, Sigma2 = Sigma2, Sigma3 = Sigma3)))

}

###### Testing the Function ###################################################
#
# lapply(1:15, mvParamConfig)
#
# # Test parameters
# params <- mvParamConfig(13)
```
BenBarnard/slidR documentation built on Jan. 2, 2018, 4:32 p.m.