Code
\begin{bmatrix} C_{xx} & C_{xy} \\ C_{xy}^{\top} & C_{yy}\end{bmatrix}
M1 MIDS/MFA/LOGOS |
Année 2024 |
\[C(X,Y) = \mathbb{E}\left[X Y^\top\right]\]
\[\begin{bmatrix} C_{xx} & C_{xy} \\ C_{xy}^{\top} & C_{yy}\end{bmatrix}\]
\begin{bmatrix} C_{xx} & C_{xy} \\ C_{xy}^{\top} & C_{yy}\end{bmatrix}
The first canonical components are the solution of the next problem
\[\begin{array}{lll}\text{Maximize} & & u^\top C_{xy} v \\\text{subject to} & & u^\top C_{xx} uv=1 =v^\top C_{yy} v \end{array}\]
Let
\[U \times D \times V^\top\]
be a SVD of
\[C_{xx}^{-1/2} \times C_{xy} \times C_{yy}^{-1/2}\]
The solution to the optimization problem above is
\[a = C_{xx}^{-1/2} u_1 \qquad \text{and} \qquad b= S_{yy}^{-1/2} v_1\]
where \(u_1\) and \(v_1\) are the leading left and right singular vectors of \(C_{xx}^{-1/2} \times C_{xy} \times C_{yy}^{-1/2}\), that is the first column vectors of \(U\) and \(V\).
Proof:
A sequence of canonical components of \(C_{xy}\) can be obtained from the sequence of (extended) left and right singular vectors of \(C_{xy}\) with respect to \(C_{xx}\) and \(C_{yy}\)
Proof:
R
cancor()
from base package R
/usr/lib/R/library/stats/help/cancor
?LifeCycleSavings
LifeCycleSavings |>
slice_sample(n=5)
pairs(LifeCycleSavings,
panel = panel.smooth,
main = "LifeCycleSavings data")
pop <- LifeCycleSavings |>
select(starts_with('pop'))
oec <- LifeCycleSavings |>
select(-starts_with('pop'))
res.cca <- cancor(pop, oec)
Check that the different components of the output of cancor()
satisfy all properties they should satisfy.
Design a suite of tests (using testthat
) that any contender of the implementation provided by package stats
should pass.
CCA