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

From: ivo welch <ivowel_at_gmail.com>
Date: Thu 19 Jan 2006 - 00:56:05 EST

thank you. I am still not sure how to get the scores in princomp, though:

ds= as.data.frame( cbind(rnorm(10),rnorm(10)) ) names(ds)=c("x1","x2")
ds[5,]=c(NA,NA)
pc= princomp( formula = ~ ds$x1 + ds$x2, na.action=na.omit) ds$pc1 = pc$scores[,1] #<-- error, scores has 9 obs, ds has 10 obs

is there an elegant method to do this, or do I need to learn how to operate with pc$loadings? (may I also humbly suggest that the default behavior or $scores should be to contain NA in row 5?)

Incidentally, R is a lot cleverer than I understand. pc$loadings by itself gives me wonderfully intuitive output, with names, text, different components---but I can still use p$loadings[,2]. I presume that the array operator on the "loadings" object is overloaded. very nice.

        [[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 Thu Jan 19 01:29:54 2006

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