Description Usage Arguments Value Examples
GRCCA function performs Canonical Correlation Analysis with group L2 regularization and allows to conduct Canonical Correlation Analysis in high dimensions. It imposes group L2 penalty on the coefficient vectors α and β coefficients. Specifically, if
x = (x_1, ..., x_p) and y = (y_1, ..., y_q)
are random vectors and
I_1, ..., I_K is a partition of {1, ..., p} and J_1, ..., J_L is a partition of {1, ..., q}
then GRCCA seeks for such vectors
α = (α_1, ..., α_p) and β = (β_1, ..., β_q)
that satisfy two within group constraints
||α||_w = var(α_I_1) + ... + var(α_I_K) <= t_1
and
||β||_w = var(β_J_1) + ... + var(β_J_L) <= t_2
as well as two between group constraints
||α||_b = |I_1| mean(α_I_1)^2 + ... + |I_K| mean(α_I_K)^2 <= s_1
and
||β||_b = |J_1| mean(β_J_1)^2 + ... + |J_L| mean(β_J_L)^2 <= s_2
and that maximize the correlation cor(u, v) between the linear combnations
u = <x , α> and v = <y , β>.
Here <a , b> refers to the inner product between two vectors;
α_I_k and β_J_l
are corresponding subvectors of α and β with indices belonging to I_k and J_l, respectively; and |A| referes to the set candinality. The above optimization problem is equivalet to maximizing the modified correlation coefficient
cov(<x , α>, <y , β>) / ( cov(<x , α>) + λ_1 ||α||_w + μ_1 ||α||_b )^1/2 ( var(<y , β>) + λ_2 ||β||_w + μ_2 ||β||_b )^1/2,
where
λ_1 and λ_2
control the resulting within group variation of the coefficiens and
μ_1 and μ_2
control the sparsity on a group level of the canonical coefficients α and β.
1 2 3 4 5 6 7 8 9 10 |
X |
a rectangular n x p matrix containing n observations of random vector x. |
Y |
a rectangular n x q matrix containing n observations of random vector y. |
group1 |
an integer valued vector representing the group assignment of α coefficients. By default |
group2 |
an integer valued vector representing the group assignment of β coefficients. By default |
lambda1 |
a non-negative penalty factor used for controlling the within variation of α coefficients. By default |
lambda2 |
a non-negative penalty factor used for controlling the within variation of β coefficients. By default |
mu1 |
a non-negative penalty factor used for controlling the between variation of α coefficients. By default |
mu2 |
a non-negative penalty factor used for controlling the between variation of β coefficients. By default |
A list containing the PCMS problem solution:
n.comp
– the number of computed canonical components, i.e. k = min(p, q).
cors
– the resulting k canonical correlations.
mod.cors
– the resulting k values of modified canonical correlation.
x.coefs
– p x k matrix representing k canonical coefficient vectors α[1], ..., α[k].
x.vars
– n x k matrix representing k canonical variates u[1], ..., u[k].
y.coefs
– q x k matrix representing k canonical coefficient vectors β[1], ..., β[k].
y.vars
– n x k matrix representing k canonical variates v[1], ..., v[k].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | data(X)
data(Y)
#run RCCA
n.groups = 5
#run GRCCA with no sparsity on a group level
group1 = rep(1:n.groups, rep(ncol(X)/n.groups, n.groups))
grcca = GRCCA(X, Y, group1, group2 = NULL, lambda1 = 1000, lambda2 = 0, mu1 = 0, mu2 = 0)
#check the modified canonical correlations
plot(1:grcca$n.comp, grcca$mod.cors, pch = 16, xlab = 'component', 'ylab' = 'correlation', ylim = c(0, 1))
#check the canonical coefficients for the first canonical variates
barplot(grcca$x.coefs[,'can.comp1'], col = 'orange', 'xlab' = 'X feature', ylab = 'value')
n.groups = 50
#run GRCCA with sparsity on a group level
group1 = rep(1:n.groups, rep(ncol(X)/n.groups, n.groups))
grcca = GRCCA(X, Y, group1, group2 = NULL, lambda1 = 10000, lambda2 = 0, mu1 = 100, mu2 = 0)
#check the modified canonical correlations
plot(1:grcca$n.comp, grcca$mod.cors, pch = 16, xlab = 'component', 'ylab' = 'correlation', ylim = c(0, 1))
#check the canonical coefficients for the first canonical variates
barplot(grcca$x.coefs[,'can.comp1'], col = 'orange', 'xlab' = 'X feature', ylab = 'value')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.