#############
## First example: we apply SPLA to a classic example from PCA
#############
spla(USArrests, method = "spca", para=c(0.5, 0.5, 0.5, 0.5), cor=TRUE)
## we obtain two blocks:
## 1x1 (Urbanpop) and 3x3 (Murder, Aussault, Rape).
## The large CEC of 0.922 indicates that the given structure is reasonable.
spla(USArrests, method = "spca", para=c(0.5, 0.5, 0.7, 0.5), cor=TRUE)
## we obtain three blocks:
## 1x1 (Urbanpop), 1x1 (Rape) and 2x2 (Murder, Aussault).
## The mid-ish CEC of 0.571 for (Murder, Aussault) indicates that the found
## structure might not be adequate.
#############
## Second example: we replicate a synthetic example similar to Bauer (2022)
#############
set.seed(1)
N = 500
V1 = rnorm(N,0,10)
V2 = rnorm(N,0,11)
## Create the blocks (X_1,...,X_4) and (X_5,...,X_8) synthetically
X1 = V1 + rnorm(N,0,1) #X_j = V_1 + N(0,1) for j =1,...,4
X2 = V1 + rnorm(N,0,1)
X3 = V1 + rnorm(N,0,1)
X4 = V1 + rnorm(N,0,1)
X5 = V2 + rnorm(N,0,1) #X_j = V_1 + N(0,1) for j =5,...9
X6 = V2 + rnorm(N,0,1)
X7 = V2 + rnorm(N,0,1)
X8 = V2 + rnorm(N,0,1)
X = cbind(X1, X2, X3, X4, X5, X6, X7, X8)
## Conduct SPLA to obtain the blocks (X_1,...,X_4) and (X_5,...,X_8)
## use method = "pmd" (default)
spla(X, para = 1.4)
## use method = "spca"
spla(X, method = "spca", para = c(500,60,3,8,5,7,13,4))
Run the code above in your browser using DataLab