Last chance! 50% off unlimited learning
Sale ends in
Computes the distance associated with a matching between two point patterns.
matchingdist(matching, type = NULL, cutoff = NULL, q = NULL)
A point pattern matching (an object of class "pppmatching"
).
A character string giving the type of distance to be computed.
One of "spa"
, "ace"
or "mat"
. See details below.
The value
The order of the average that is applied to the interpoint distances.
May be Inf
, in which case the maximum of the interpoint distances is taken.
Numeric value of the distance associated with the matching.
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 q
-th order average of the cutoff
)
and 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 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
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"
.
# NOT RUN {
# 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)
# }
Run the code above in your browser using DataLab