I know how to do factor and canonical correlation analysis on raw data in R. But sometimes we only having correlation matrices for the data. I'd like to know any R functions which can take correlation matrices as input for factor and canonical correlation analysis. It is easy to write dedicated functions but it is nicer to have some built-in tested functions.
Ideas for factor analysis and PCA:
# get some Big 5 personality data and pretend we only have cor matrix and n library(psych) bfi <- na.omit(bfi[, 1:25]) xcor <- cor(bfi) xn <- nrow(bfi) # factor analysis using correlation matrix factanal(covmat=xcor, n.obs=xn, factors=5) # Principal components analysis using psych package psych::principal(r=xcor, n.obs=xn, nfactors=5)
Canonical correlation analysis
- I don't think
cancortakes correlation matrices as input.
- You could use one of the sem packages in R to perform canonical correlation analysis. I know that
semcan take a correlation matrix as input.
For factor analysis, the psych package accepts either raw data or a correlation matrix (see e.g.,
factor.pa()). About CCA, I'm not aware of a package that would take correlation matrices as input instead of row data tables.
I know this is an old topic, but I was having the same problem and came across this page: Canonical Correlation Analysis. I just tried out this guy's function for myself and it works perfectly (albeit with slightly less output than the better known R functions that only accept raw data as input). Hope this helps you or somebody like you (and me) in the future.