Algorithm:
The output to create will be a vector of numbers
that correspond to where the
th point should be connected
to.
Here are some examples with Splus:
mstree(vincr[1:10, ])
> mstree(vincr[1:10, ])
$x:
[1] 4.20959759 -3.70445704 4.54166603 7.22903347 4.89603710 2.28360796
[7] 0.00000000 -2.00589728 1.03156424 0.04926162
$y:
[1] -7.0463328 -6.4673190 0.4050449 -0.3888339 -2.2247181 0.0000000
[7] 0.0000000 -3.2911484 -0.8079203 -1.5704904
$mst:
[1] 10 8 6 3 3 7 10 10 10
mst: vector of length nrow(x)-1 describing the edges in the
minimal spanning tree. The ith value in this vector is an
observation number, indicating that this observation and
the ith observation should be linked in the minimal span-
ning tree.
$order:
[,1] [,2]
[1,] 4 7
[2,] 3 10
[3,] 5 6
[4,] 6 9
[5,] 7 8
[6,] 10 3
[7,] 1 1
[8,] 9 4
[9,] 8 5
[10,] 2 2
order: matrix, of size nrow(x) by 2, giving two types of ord-
ering: The first column presents the standard ordering
from one extreme of the minimal spanning tree to the oth-
er. This starts on one end of a diameter and numbers the
points in a certain order so that points close together in
Euclidean space tend to be close in the sequence. The
second column presents the radial ordering, based on dis-
tance from the center of the minimal spanning tree. These
can be used to detect clustering. See below for graph
theory definitions.
plot(x, y) # plot original data
mst <- mstree(cbind(x, y), plane=F) # minimal spanning tree
# show tree on plot
segments(x[seq(mst)], y[seq(mst)], x[mst], y[mst])
i <- rbind(iris[,,1], iris[,,2], iris[,,3])
tree <- mstree(i) # multivariate planing
plot(tree, type="n") # plot data in plane
text(tree, label=c(rep(1, 50), rep(2, 50), rep(3, 50))) # identify points
# get the absolute value stress e
distp <- dist(i)
dist2 <- dist(cbind(tree$x, tree$y))
e <- sum(abs(distp - dist2))/sum(distp)
0.1464094