matchingdist | R Documentation |
Computes the distance associated with a matching between two point patterns.
matchingdist(matching, type = NULL, cutoff = NULL, q = NULL)
matching |
A point pattern matching (an object of class |
type |
A character string giving the type of distance to be computed.
One of |
cutoff |
The value |
q |
The order of the average that is applied to the interpoint distances.
May be |
Computes the distance specified by type
, cutoff
, and order
for a point matching. If any of these arguments are not provided, the function
uses the corresponding elements of matching
(if available).
For the type "spa"
(subpattern assignment) it is assumed that the points
of the point pattern with the smaller cardinality m
are matched to a
m
-point subpattern of the point pattern with the larger
cardinality n
in a 1-1 way. The distance
is then given as the q
-th order average of the m
distances between
matched points (minimum of Euclidean distance and cutoff
)
and n-m
"penalty distances" of value cutoff
.
For the type "ace"
(assignment only if cardinalities equal) the matching
is assumed to be 1-1 if the cardinalities of the point patterns are
the same, in which case the q
-th order average of the matching distances
(minimum of Euclidean distance and cutoff
) is taken. If the cardinalities
are different, the matching may be arbitrary and the distance returned is always
equal to cutoff
.
For the type mat
(mass transfer) it is assumed that each point of
the point pattern with the smaller cardinality m
has mass 1
,
each point of the point pattern with the larger cardinality n
has mass m/n
,
and fractions of these masses are matched in such a way that each point
contributes exactly its mass. The distance is then given as the q
-th
order weighted average of all distances (minimum of Euclidean distance
and cutoff
) of (partially) matched points with weights equal to the
fractional masses divided by m
.
If the cardinalities of the two point patterns are equal,
matchingdist(m, type, cutoff, q)
yields the same result
no matter if type
is "spa"
, "ace"
or
"mat"
.
Numeric value of the distance associated with the matching.
.
pppdist
pppmatching.object
# an optimal matching
X <- runifrect(20)
Y <- runifrect(20)
m.opt <- pppdist(X, Y)
summary(m.opt)
matchingdist(m.opt)
# is the same as the distance given by summary(m.opt)
# sequential nearest neighbour matching
# (go through all points of point pattern X in sequence
# and match each point with the closest point of Y that is
# still unmatched)
am <- matrix(0, 20, 20)
h <- matrix(c(1:20, rep(0,20)), 20, 2)
h[1,2] = nncross(X[1],Y)[1,2]
for (i in 2:20) {
nn <- nncross(X[i],Y[-h[1:(i-1),2]])[1,2]
h[i,2] <- ((1:20)[-h[1:(i-1),2]])[nn]
}
am[h] <- 1
m.nn <- pppmatching(X, Y, am)
matchingdist(m.nn, type="spa", cutoff=1, q=1)
# is >= the distance obtained for m.opt
# in most cases strictly >
opa <- par(mfrow=c(1,2))
plot(m.opt, main="optimal")
plot(m.nn, main="nearest neighbour")
text(X, 1:20, pos=1, offset=0.3, cex=0.8)
par(opa)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.