[R] Questions on formula in princomp

Sasha Pustota popgen at gmail.com
Fri Apr 14 21:25:31 CEST 2006

Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
> Sasha Pustota <popgen at gmail.com> wrote:
> > ir <- rbind(iris3[,,1], iris3[,,2], iris3[,,3])
> > lir <- data.frame(log(ir))
> > names(lir) <- c("a","b","c","d")
> >
> > I'm trying to understand the meaning of expressions like "~ a+b+c+d",
> > used with princomp, e.g.
> > princomp(~ a+b+c+d, data=lir, cor=T)
> > By inspection, it looks like the result is the same as in
> > princomp(lir, cor = T).
> Yes, princomp.formula just takes the model matrix of the formula
> and passes it to princomp.default.

Thanks. A further question. If I set some values to NA, a call

princomp(~., data=mir, cor=T, na.action=na.omit)$scores

indicates there have been predicted values imputed in place of NA.
The documentation says 'napredict' is used but I can't find details.
My guess is that these are predicted from linear multiple regression
of other columns on NAs. However, what method is used exactly, in
the case of princomp?  (and how do I find out these things?)

More information about the R-help mailing list