Dear all, I did performed a PCA analysis (using prcomp function) on a data matrix. Then I would like to reconstruction part of the original data set using only specifics and choosen eigenvectors. I would like to know if there is a function under R witch can perform this reconstruction. Regards -- ------------------------------------------------ Emmanuel Poizot Cnam/Intechmer B.P. 324 50103 Cherbourg Cedex Phone (Direct) : (00 33)(0)233887342 Fax : (00 33)(0)233887339 ------------------------------------------------
See ?rconst in package ade4. You will need to fit the PCA with dudi.pca (same package). Best, Renaud 2006/11/9, Poizot Emmanuel <poizot at cnam.fr>:> Dear all, > > I did performed a PCA analysis (using prcomp function) on a data matrix. > Then I would like to reconstruction part of the original data set using > only specifics and choosen eigenvectors. > I would like to know if there is a function under R witch can perform > this reconstruction. > Regards > > -- > > ------------------------------------------------ > Emmanuel Poizot > Cnam/Intechmer > B.P. 324 > 50103 Cherbourg Cedex > > Phone (Direct) : (00 33)(0)233887342 > Fax : (00 33)(0)233887339 > ------------------------------------------------ > > > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > >-- Renaud LANCELOT D?partement Elevage et M?decine V?t?rinaire (EMVT) du CIRAD Directeur adjoint charg? des affaires scientifiques CIRAD, Animal Production and Veterinary Medicine Department Deputy director for scientific affairs Campus international de Baillarguet TA 30 / B (B?t. B, Bur. 214) 34398 Montpellier Cedex 5 - France T?l +33 (0)4 67 59 37 17 Secr. +33 (0)4 67 59 39 04 Fax +33 (0)4 67 59 37 95
Also new values can be easy calculated from prcomp object: Data <- scale(iris[,1:4],center=TRUE,scale=TRUE) iris.pc <- prcomp(Data) # Explained variation (iris.pc$sdev^2/sum(iris.pc$sdev^2))*100 # Loadings iric.pc$rotation #Scores iris.pc$x #Fitted Values for each PC # Xfit = T*P^t PCfit <- function (i,pcdata) {PCI <- pcdata$x[,i]%*%t(pcdata$rotation[,i])} Fitted <- lapply (c(1:4),PCfit,pcdata=iris.pc) for ( i in c(1:4) ) { assign (paste("IrisPC",i,sep=""),Fitted[[i]])} #Residuals EPC1 <- round(Data - IrisPC1,3) EPC2 <- round(Data - (IrisPC1+IrisPC2),3) EPC3 <- round(Data - (IrisPC1+IrisPC2+IrisPC3),3) EPC4 <- round(Data - (IrisPC1+IrisPC2+IrisPC3+IrisPC4),3) # 0 Andris Jankevics On Piektdiena, 10. Novembris 2006 05:58, Renaud Lancelot wrote:> See ?rconst in package ade4. You will need to fit the PCA with > dudi.pca (same package). > > Best, > > Renaud > > 2006/11/9, Poizot Emmanuel <poizot at cnam.fr>: > > Dear all, > > > > I did performed a PCA analysis (using prcomp function) on a data matrix. > > Then I would like to reconstruction part of the original data set using > > only specifics and choosen eigenvectors. > > I would like to know if there is a function under R witch can perform > > this reconstruction. > > Regards > > > > -- > > > > ------------------------------------------------ > > Emmanuel Poizot > > Cnam/Intechmer > > B.P. 324 > > 50103 Cherbourg Cedex > > > > Phone (Direct) : (00 33)(0)233887342 > > Fax : (00 33)(0)233887339 > > ------------------------------------------------ > > > > > > > > ______________________________________________ > > R-help at stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html and provide commented, > > minimal, self-contained, reproducible code.