diss_to_neighbors: From dissimilarity matrix to neighbors

View source: R/search_neighbors_helpers.R

diss_to_neighborsR Documentation

From dissimilarity matrix to neighbors

Description

internal

Usage

diss_to_neighbors(
  diss_matrix,
  k = NULL,
  k_diss = NULL,
  k_range = NULL,
  spike = NULL,
  return_dissimilarity = FALSE,
  skip_first = FALSE
)

Arguments

diss_matrix

a matrix representing the dissimilarities between observations in a matrix Xu and observations in another matrix Xr. Xr in rows Xu in columns.

k

an integer value indicating the k-nearest neighbors of each observation in Xu that must be selected from Xr.

k_diss

an integer value indicating a dissimilarity treshold. For each observation in Xu, its nearest neighbors in Xr are selected as those for which their dissimilarity to Xu is below this k_diss threshold. This treshold depends on the corresponding dissimilarity metric specified in diss_method. Either k or k_diss must be specified.

k_range

an integer vector of length 2 which specifies the minimum (first value) and the maximum (second value) number of neighbors to be retained when the k_diss is given.

spike

a vector of integers indicating what observations in Xr (and Yr) must be 'forced' to always be part of all the neighborhoods.

return_dissimilarity

logical indicating if the input dissimilarity must be mirroed in the output.

skip_first

a logical indicating whether to skip the first neighbor or not. Default is FALSE. This is used when the search is being conducted in symmetric matrix of distances (i.e. to avoid that the nearest neighbor of each observation is itself).


resemble documentation built on April 21, 2023, 1:13 a.m.