Hi Hinduja,

my.pc is now your model in a way made of multiple what we call principal components. Now you have to take a decision how many principal component or in other words how variance do I want to keep??

it looks like this

newpac <-predict(my.prc, newdata=testdata$mydata)

and we go now you the principal component for you testdata

newpac[,1] …newpac[,2] etc they are you new variables

so if you keep testdata you remove them and add new pac[,1] , new pac[,2] etc…,

rbind(testdata, var1=new.pac[,1] …, ) type

which variance ?? you have to square the individual standard deviation and divided by sum of all the standard deviations which give (we do this on the train data)

my.prc $sdev[1]^2/sum(my.prc $sdev^2) this will be the variance you explain by using the first principal component ,

you can continue with sum(my.prc $sdev[1]^2+my.prc $sdev[2]^2… )/ sum(my.prc $sdev^2) until you reach the variance you want usually by 3 or 4 you should be at 90% or more

Good luck