landmarks_lastfirst: Neighborhood-based Landmark Sets

Description Usage Arguments Details Author(s) Examples

View source: R/landmarks-lastfirst.r

Description

Compute landmark sets based on nearest neighborhoods.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
firstlast(x, y = NULL, dist_method = "euclidean", ties_method = "min")

lastfirst(x, y = NULL, dist_method = "euclidean", ties_method = "min")

landmarks_lastfirst(
  x,
  dist_method = "euclidean",
  ties_method = "min",
  pick_method = "first",
  num = NULL,
  cardinality = NULL,
  frac = FALSE,
  seed_index = 1L,
  engine = NULL,
  cover = FALSE,
  extend_num = extension(mult = 0, add = 0),
  extend_cardinality = extension(mult = 0, add = 0)
)

Arguments

x

a data matrix.

y

a data matrix of the same dimension as x; if NULL, taken to be x.

dist_method

a character string specifying the distance metric to use; passed to proxy::dist(method). Any distance measure in the proxy package is supported.

ties_method

a character string specifying the method for handling ties; passed to rank(ties.method). Only "min" and "max" have been tested and are recommended.

pick_method

a character string specifying the method for selecting one among indistinguishable points, either "first" (the default), "last", or "random".

num

a positive integer; the desired number of landmark points, or of sets in a neighborhood cover.

cardinality

a positive integer; the desired cardinality of each landmark neighborhood, or of each set in a landmark cover.

frac

logical; whether to treat cardinality as a fraction of the cardinality of x.

seed_index

an integer (the first landmark to seed the algorithm) or one of the character strings "random" (to select a seed uniformly at random) and "firstlast" (to select a seed from the firstlast set).

engine

character string specifying the implementation to use; one of "C++" or "R". When not specified, the R engine is used.

cover

logical; whether to return a data frame of landmark indices and cover sets (by member index) rather than only a vector of landmark indices.

extend_num, extend_cardinality

length-two numeric vectors used to extend landmark parameters for cover set construction. See extension().

Details

These functions adapt the maxmin procedure to produce landmark points dispersed according to the orders in which they are reached from each other, rather than to their distances from each other. (Say more.)

One, both, or neither of num and cardinality may be passed values. If neither is specified, then num is defaulted to the minimum of 24L and the number of distinct rows of x. If the values yield neighborhoods that do not cover x, then, effectively, num is increased until the cardinality necessary to cover x is at most cardinality. To generte a complete landmark set, use cardinality = 1L.

Author(s)

Jason Cory Brunson

Yara Skaf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
set.seed(4)
# small circle sample
X <- tdaunif::sample_circle(n = 6L)
# random seed index
l <- landmarks_lastfirst(X, seed_index = "random")
# plot landmark order at point positions
plot(X, asp = 1, pch = NA)
text(X, labels = order(l))
# add duplicate points
X <- rbind(X, X[sample(nrow(X), 6, replace = TRUE), , drop = FALSE])
# firstlast seed index
l <- landmarks_lastfirst(X, seed_index = "firstlast")
# plot landmark order at point positions
plot(X, asp = 1, pch = NA)
text(X + .1 * cbind(floor((1:12 - 1) / 6) - .5, 0), labels = order(l))

corybrunson/maxmin documentation built on Feb. 3, 2022, 1:58 a.m.