Re: [R] princomp() with missing values in panel data?

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 17 Jan 2006 - 16:50:09 EST

See ?na.exclude (on the same page as na.omit)

On Mon, 16 Jan 2006, ivo welch wrote:

> dear R wizards: the good news is that I know how to omit missing
> observations and run a principal components analysis.
>
> p= princomp( na.omit( dataset ) )
> p$scores[ ,1] # the first factor
>
> (where dataset contains missing values; incidentally, princomp(retailsmall,
> na.action=na.omit) does not work for me, so I must be doing something wrong,
> here.)

See ?princomp: only the formula method has an na.action argument.

> the bad news is that I would like NA observations to be retained as
> NA, so that I can reinsert the factors into the data set:
> dataset$first.factor = p$scores[,1]
> there must be an elegant way of doing this. help appreciated.
>
> may I humbly suggest that in linear models, it would be intuitive if the
> default would be for NA's to be ignored in the model computations, and that
> the functions residuals and fitted (and similar, such as scores() ) to
> understand when a particular obs num should be NA?

There is no function scores().

> help, as always, appreciated.
>
> sincerely,
>
> /ivo welch
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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
>

-- 
Brian D. Ripley,                  ripley@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

______________________________________________
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
Received on Tue Jan 17 16:57:09 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:04 EST