0
$\begingroup$

I am trying to use sparse canonical correlation analysis as implemented in the R PMA package. I'm finding that the correlations output by the package seem slightly inconsistent with the ones you would get by taking the correlations between the sparse CCA scores. There is also some output from the PMA:CCA function which seems like debugging output during its run.

Here is a reproducible example:

# CCA with penalization function imported from PMA
library(PMA)

# Use CCA only for sample dataset nutrimouse
library(CCA)

# Grab sample data
data("nutrimouse")

# Set up X and Y matrices
X=as.matrix(nutrimouse$gene)
Y=as.matrix(nutrimouse$lipid)

# Run penalized CCA - also has some strange ?debugging? output
pma <- PMA::CCA(X,Y,K=3)

# Calculate scores
score.x <- X %*% pma$u
score.y <- Y %*% pma$v

# Calculate correlations between scores
sapply(1:3,FUN=function(x) cor(score.x[,x],score.y[,x],method="pearson"))

# Scores output by module - shouldn't this be identical to output from line above?
pma$cors

Which gives the following output:

> 
> # Grab sample data
> data("nutrimouse")
> 
> # Set up X and Y matrices
> X=as.matrix(nutrimouse$gene)
> Y=as.matrix(nutrimouse$lipid)
> 
> # Run penalized CCA - also has some strange ?debugging? output
> pma <- PMA::CCA(X,Y,K=3)
12
123456789
12345
> 
> # Calculate scores
> score.x <- X %*% pma$u
> score.y <- Y %*% pma$v
> 
> # Calculate correlations between scores
> sapply(1:3,FUN=function(x) cor(score.x[,x],score.y[,x],method="pearson"))
[1] 0.8438400 0.8200629 0.8200418
> 
> # Scores output by module - shouldn't this be identical to output from line above?
> pma$cors
[1] 0.8802205 0.8460601 0.8477227

Shouldn't the last two lines output be the same? Any hints?

$\endgroup$
0
0
$\begingroup$

Answer posted on Stack Overflow:

  1. CCA standardizes the input data, accounting for the difference in scores
  2. The numbers are a progress trace, which can be suppressed with the trace=FALSE option
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.