Correlation matrix as input for PCA

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Correlation matrix as input for PCA

Kristin19
This post has NOT been accepted by the mailing list yet.
Hi,

I'm relatively new to R and not practiced at writing my own functions yet. I've seen a previous question posted here before that was similar to mine but that wasn't quite answered. I have a correlation matrix created from 12 very large rasters (too big to read in). I would like to perform a pca but it would be much faster and more efficient if I could use the correlation matrix already created as the only input. I'm aware that princomp allows you to input a covariance matrix, but you also have to use the original data. Does a pca function already exist where the only input is a correlation or covariance matrix? Thank you in advance for your help!

-Kristin

Reply | Threaded
Open this post in threaded view
|

Re: Correlation matrix as input for PCA

Mark Difford
This post has NOT been accepted by the mailing list yet.
On Jun 24, 2013 at 1:29am Kristin wrote:

> I've seen a previous question posted here [https://stat.ethz.ch/pipermail/r-help/2008-November/178694.html] before that
> was similar to mine but that wasn't quite answered....I'm aware that princomp allows you to input a covariance matrix,
> but you also have to use the original data. Does a pca function already exist where the only input is a correlation or
> covariance matrix?

Yes, princomp. The QA you point us to was answered, as you would have found if you had tried Professor Ripley's example (repeated below with a slight modification for added clarity).

##
myCor <- cor(USArrests)
myCor
princomp(covmat = myCor)
#princomp(x = myCor)   ## ibid
rm(myCor)

Mark.
Mark Difford (Ph.D.)
Research Associate
Botany Department
Nelson Mandela Metropolitan University
Port Elizabeth, South Africa