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

From: ivo welch <ivowel_at_gmail.com>
Date: Tue 17 Jan 2006 - 09:34:51 EST

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.) 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?

help, as always, appreciated.


/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 Received on Tue Jan 17 09:43:25 2006

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