Canonical Correlation
-
atrad
Canonical Correlation
I'm trying to do canonical correlation analysis in RATS. If anyone has a piece of code that allows me to implement this procedure, I'd be grateful if they could post it on this site.
Actually, the Johansen MLE procedure for estimating cointegrating vectors is an application of canonical correlations (of the first differences on the lag levels after eliminating short-term components). If S is the grand covariance matrix of the Y,X variables, then the following (which has been stripped from the JOHMLE procedure) computes the canonical vectors as the columns of eigvec.
compute %%s00=%xsubmat(s, 1,numvar, 1,numvar)
compute %%s11=%xsubmat(s,numvar+1,sweepv,numvar+1,sweepv)
compute %%s01=%xsubmat(s, 1,numvar,numvar+1,sweepv)
*
* Compute the generalized eigenvalues and vectors
*
compute s10_00_01=tr(%%s01)*inv(%%s00)*%%s01
eigen(general=%%s11) s10_00_01 eigval eigvec
compute %%s00=%xsubmat(s, 1,numvar, 1,numvar)
compute %%s11=%xsubmat(s,numvar+1,sweepv,numvar+1,sweepv)
compute %%s01=%xsubmat(s, 1,numvar,numvar+1,sweepv)
*
* Compute the generalized eigenvalues and vectors
*
compute s10_00_01=tr(%%s01)*inv(%%s00)*%%s01
eigen(general=%%s11) s10_00_01 eigval eigvec