qt4 <- function(s)
{
n <- nrow(s)
h <- s+t(s)
diag(h) <- 0
diag(h) <- -apply(h, 1, sum)
res <- eigen(h)
colnames(res$vectors) <- names(res$values) <- paste("Axis", 1:n)
rownames(res$vectors) <- paste("Object", 1:n)
res$values <- res$values[res$values > 1e-5]
ax <- length(res$values)
res$vectors <- res$vectors[,1:ax]
if (ax > 2) {
plot(res$vectors[,1:2])
abline(v=0, h=0)
text(res$vectors[,1], res$vectors[,2], 1:n, pos=4, offset=.2)
}
res
}
s <- matrix(c(
0, -3, -5, -1,
-1, 0, -2, -3,
-2, -3, 0, -2,
-3, -4, -1, 0
), byrow=TRUE, ncol=4)
qt4(s)
結果
$values
Axis 1 Axis 2 Axis 3
23.14960 21.17475 15.67565
$vectors
Axis 1 Axis 2 Axis 3
Object 1 -0.3851933 0.6229948 0.4620645
Object 2 -0.6014664 -0.5291030 -0.3290717
Object 3 0.5327996 -0.4516184 0.5120210
Object 4 0.4538601 0.3577266 -0.6450138
二軸以上が求まった場合には,第一軸と第二軸で対象のプロットを行う