[prev in list] [next in list] [prev in thread] [next in thread]
List: r-help
Subject: Re: [R] Axis scaling for PCA biplot
From: Ivan Krylov <krylov.r00t () gmail ! com>
Date: 2022-11-16 10:30:49
Message-ID: 20221116133049.7c67880f () arachnoid
[Download RAW message or body]
В Tue, 15 Nov 2022 12:53:30 +0100
Christian Hennig <christian.hennig@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,
Ivan
[1]:
https://github.com/r-devel/r-svn/blob/c5f16db96ad76504893a1070d3b46b4093bb49c4/src/library/stats/R/biplot.R#L80-L95
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic