Hello, I have a problem with the princomp method, it seems stupid but I don't know how to handle it. I have a dataset with some regular data and some outliers. I want to calculate a PCA on the regular data and get the scores for all data, including the outliers. Is this possible on R? Thank you for helping!!! -- View this message in context: http://www.nabble.com/Help-about-princomp-tf3630184.html#a10136737 Sent from the R help mailing list archive at Nabble.com.
On Mon, 23 Apr 2007, annina wrote:> > Hello, > I have a problem with the princomp method, it seems stupid but I don't know > how to handle it. > I have a dataset with some regular data and some outliers. I want to > calculate a PCA on the regular data and get the scores for all data, > including the outliers. Is this possible on R?Yes. Do you know which are the outliers? You can either fit to the 'regular data' with princomp and use predict() to get the 'scores' for all the data, or use a robust method to find the 'covmat' argument (as the help page says, you could use cov.mcd from MASS) and call princomp() on all the data. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Hi Annina, You may use the dudi.pca function in the ade4 package. PCA <- dudi.pca(your_data, scale = FALSE, scan = FALSE) # to get scores PCA$li and you're done. Maybe have a look at ?dudi.pca Christophe annina a ?crit :> Hello, > I have a problem with the princomp method, it seems stupid but I don't know > how to handle it. > I have a dataset with some regular data and some outliers. I want to > calculate a PCA on the regular data and get the scores for all data, > including the outliers. Is this possible on R? > Thank you for helping!!!-- ================================================== *Christophe BONENFANT* UMR CNRS 5558, Laboratoire de Biom?trie et Biologie Evolutive Universit? Claude Bernard Lyon 1 43, Boulevard du 11 Novembre 1918 F-69622 Villeurbanne cedex, FRANCE Phone : (+33) 8 72 20 98 73 Courriel/E-mail: bonenfan[at]biomserv[dot]univ-lyon1[dot]fr _(~)_ )"( (@_@) /-----) ( Comtois, rends-toi ! Nenni ma foi ! / | | | * / \`--/ \ ~~ ~~ "Error 404 - Brain not found"...
annina <wossona <at> yahoo.co.uk> writes:> > > Hello, > I have a problem with the princomp method, it seems stupid but I don't know > how to handle it. > I have a dataset with some regular data and some outliers. I want to > calculate a PCA on the regular data and get the scores for all data, > including the outliers. Is this possible on R? > Thank you for helping!!!Dear Annina, Yes, this is possible in R. Both 'prcomp' (that I recommend) and 'princomp? have 'predict' method which can have 'newdata' as an argument. The following assumes that 'keep' is a vector which is TRUE for cases you keep, and FALSE for those ignored: pc <- prcomp(x[keep,]) predict(pc, newdata=x) cheers, Jari Oksanen
Apparently Analagous Threads
- testing significance of axis loadings from multivariate dudi.mix
- Snow parLapply
- How to use PC1 of PCA and dim1 of MCA as a predictor in logistic regression model for data reduction
- Obtain residuals from a Principal Component Analysis
- biplot drawing conc ellipses