object.distances: Calculate distances between object vectors in a SOM

View source: R/object.distances.R

object.distancesR Documentation

Calculate distances between object vectors in a SOM

Description

This function calculates the distance between objects using the distance functions, weights and other attributes of a trained SOM. This function is used in the calculation of the U matrix in function plot.missSOM using the type = "dist.neighbours" argument.

Usage

object.distances(kohobj, type = c("data", "ximp", "codes"))

Arguments

kohobj

An object of class missSOM.

type

Whether to calculate distances between the data objects, or the codebook vectors.

Value

An object of class dist, which can be directly fed into (e.g.) a hierarchical clustering.

See Also

unit.distances, imputeSOM

Examples

data(wines)

## Data with no missing values 
set.seed(7)
sommap <- imputeSOM(scale(wines), grid = somgrid(6, 4, "hexagonal"))
obj.dists <- object.distances(sommap, type = "data")
code.dists <- object.distances(sommap, type = "codes")

## Data with missing values 
X <- scale(wines)
X[1:5, 1] <- NaN
sommap <- imputeSOM(X, grid = somgrid(6, 4, "hexagonal"))
obj.dists <- object.distances(sommap, type = "ximp")
code.dists <- object.distances(sommap, type = "codes")


missSOM documentation built on May 5, 2022, 9:06 a.m.