Hi,
I think that the documentation for the biplot function `biplot.princomp' is
inconsistent with what it actually does. Here is what the documentation
states:
pc.biplot
If true, use what Gabriel (1971) refers to as a "principal component
biplot", with lambda = 1 and observations scaled up by sqrt(n) and
variables
scaled down by sqrt(n). Then inner products between variables approximate
covariances and distances between observations approximate Mahalanobis
distance.
Here is what the code looks like:
> getAnywhere("biplot.princomp")
A single object matching 'biplot.princomp' was found
It was found in the following places
registered S3 method for biplot from namespace stats
namespace:stats
with value
function (x, choices = 1L:2L, scale = 1, pc.biplot = FALSE, ...)
{
if (length(choices) != 2)
stop("length of choices must be 2")
if (!length(scores <- x$scores))
stop(gettextf("object '%s' has no scores",
deparse(substitute(x))),
domain = NA)
lam <- x$sdev[choices]
if (is.null(n <- x$n.obs))
n <- 1
lam <- lam * sqrt(n)
if (scale < 0 || scale > 1)
warning("'scale' is outside [0, 1]")
if (scale != 0)
lam <- lam^scale
else lam <- 1
if (pc.biplot)
lam <- lam/sqrt(n)
biplot.default(t(t(scores[, choices])/lam), t(t(x$loadings[,
choices]) * lam), ...)
invisible()
}
1. Let us consider the default options: scale = 1 and pc.biplot FALSE.
Now, lam = x$sdev * sqrt(n). Hence, the observations (scores) are
scaled down by eigenvalue * sqrt(n) and variables (loadings) are scaled up
by eigenvalue * sqrt(n).
2. Now consider: scale = 1 and pc.biplot = TRUE. We have, lam x$sdev .
The observations are scaled down by eigenvalue and variables are
scaled up by eigenvalue.
Thus, in either case the documentation does not seem to be consistent with
the implementation. Am I missing something here?
Thanks & Best,
Ravi.
----------------------------------------------------------------------------
------------------------------
Ravi Varadhan, Ph.D.
Assistant Professor,
Center on Aging and Health,
Johns Hopkins University School of Medicine
(410)502-2619
rvaradhan@jhmi.edu
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml
[[alternative HTML version deleted]]