Re: [R] Help about princomp

2007-04-23 Thread Jari Oksanen
annina  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

__
R-help@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.


Re: [R] Help about princomp

2007-04-23 Thread Christophe Bonenfant
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"...

__
R-help@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.


Re: [R] Help about princomp

2007-04-23 Thread Prof Brian Ripley
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,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
R-help@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.


[R] Help about princomp

2007-04-23 Thread annina

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.

__
R-help@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.