[R] prcomp & eigenvectors
Bill Simpson
William.Simpson at drdc-rddc.gc.ca
Tue Jun 22 14:44:33 CEST 2004
I have the following situation I want to analyse with prcomp.
Each subject has a curve called the contrast sensitivity function (CSF).
This curve's overall shape is due to the additive output of 3 "channels"
(eigenvectors).
#this shows 3 SF channels; net CSF = c1 + c2+c3
x<-1:100
c1<-dnorm(x,mean=20,sd=20)
c2<-dnorm(x,mean=50,sd=20)
c3<-dnorm(x,mean=80,sd=20)
s1<-1;s2<-1;s3<-1
net<-c1*s1 + c2*s2 + c3*s3
plot(x,net)
lines(x,c1);lines(x,c2);lines(x,c3)
Given the CSFs of many subjects, I was hoping that prcomp could show me
the shapes of the constituent channels. I checked this with a simulation.
####simulation where each subject has diff weighting (scores) of channels
nsim<-50
csf<-matrix(nrow=nsim,ncol=100)
#one row per subject, cols represent the csf
for(i in 1:nsim)
{
s1<-runif(1);s2<-runif(1);s3<-runif(1)
csf[i,]<-c1*s1 + c2*s2 + c3*s3
}
out<-prcomp(csf)
#the cols of out$rotation are the tuning curves of the various
#channels = factor loadings = eigenvectors
plot(out$rotation[,1],type="l",col=1) #PC1
lines(out$rotation[,2],col=2) #PC2
lines(out$rotation[,3],col=3) #PC3
1. This plot of the three channels does not look like the original. Am I
correct that the output of prcomp is a linear transformation of the true
channels? If so, can anyone suggest how I might get the real channels out?
Maybe additional info (what?) is needed to be able to do this.
2. I can average all the input CSFs; how do find the average fitted output
CSF using the out object?
Thanks very much for any help
Bill Simpson
More information about the R-help
mailing list