toscca-vignette

library(toscca)
library(ggplot2)

toscca

Canonical Correlation Analysis

We use the method described in the paper, Thresholded Ordered Sparse Canonical Correlation Analysis (TOSCCA), to uncover the underlying processes linking the data.

X = standardVar(X0)
Y = standardVar(Y0)
K = 4                                       # number of components to be estimated
nonz_x = rep(100, K)                        # number of nonzero variables for X
nonz_y = rep(100, K)                        # number of nonzero variables for Y
init   = "uniform"                          # type of initialisation
cca_toscca  = toscca(X, Y, nonz_x, nonz_y, K, init, combination = FALSE, silent = TRUE, toPlot = FALSE, type= 1)
cpev_toscca = sapply(1:K, function(k) cpev.toscca(X, cca_toscca$alpha[,1:k]))

# perm_toscca = perm.toscca(X, Y, nonz_x, nonz_y, K = K, init, draws = 100, cancor = cca_toscca$cancor)

tosccamm

Estimate the canonical weights and latent paths for \(K\) components.

res_k = list()

X.temp = XX2
Y.temp = YY2

res_k <- toscca(X.temp, Y.temp, folds = 2, type = 2, K = 2, toPlot = FALSE,
                                            nonzero_a = nonz_a, nonzero_b = nonz_b,
                                            model = "lme", lmeformula = " ~ 0 + poly(time,3) + (1|id)", silent = TRUE)
#> nonzero_a must have length 1 or K.
#> nonzero_b must have length 1 or K.
#> Invalid initialisation. Switched to uniform

Results

Latent paths for \(k=1\) and \(k=2\)

Figures 3.a and 3.b in manuscript.