[R] Axis scaling for PCA biplot

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Wed Nov 16 11:30:49 CET 2022

В Tue, 15 Nov 2022 12:53:30 +0100
Christian Hennig <christian.hennig using unibo.it> пишет:

> The default value of scale seems to be 1, but then (1-scale) is zero
> so I'd assume data to be unscaled, but that should have reproduced
> the "plot" scale, shouldn't it?

I think this might be a documentation error. What actually happens
inside biplot.princomp is a bit different [1]:

   lam <- x$sdev[choices]
   n <- x$n.obs %||% 1
   lam <- lam * sqrt(n)
   if(scale != 0) lam <- lam^scale else lam <- 1
   biplot.default(t(t(scores[, choices]) / lam),
		   t(t(x$loadings[, choices]) * lam), ...)

Every score is divided by standard deviations (square roots of the
eigenvalues of the covariance matrix) and the square root of the number
of samples to the power of `scale`, while the loadings are multiplied
by the same numbers.

I am not sure why the singular values have to be multiplied by sqrt(n)
(the same thing happens in biplot.prcomp), but other than that, I think
that the documentation should say "the observations are scaled by
|lambda ^ -scale|", not (1-scale).

Passing scale = 0, on the other hand, should reproduce the "plot" scale.

Best regards,


More information about the R-help mailing list