Learn R Programming

bootkmeans (version 1.0.0)

bootk.hardsoftvis: Visualize hard vs. soft assignments from bootstrap \(k\)-means

Description

Plots the results of boot.kmeans highlighting which observations are assigned with full certainty (hard) versus fractional out-of-bag membership (soft/fuzzy). Either produces a full scatterplot matrix using all variables or a 2D scatterplot of chosen variables.

Usage

bootk.hardsoftvis(data = NULL, res, plotallvars = FALSE, var1 = NULL, var2 = NULL)

Value

No return value, called for side effects (produces a visualization of hard vs. soft cluster assignments from boot.kmeans results).

Arguments

data

Numeric data frame or matrix used for clustering in boot.kmeans. Required.

res

Result list returned from boot.kmeans (an object of class "BSKMeans").

plotallvars

Logical; if TRUE, plot all pairwise scatterplots via pairs, otherwise FALSE requires var1 and var2 arguments for a 2D scatterplot. Default FALSE.

var1

Integer column number for the x-axis variable when plotallvars = FALSE.

var2

Integer column number for the y-axis variable when plotallvars = FALSE.

Author

Jesse S. Ghashti jesse.ghashti@ubc.ca and Jeffrey L. Andrews jeff.andrews@ubc.ca

Details

Each observation is classified as hard if any entry of its membership row U[i,] is exactly 1, and soft otherwise. These categories are mapped to colors green for hard assignments, blue for soft/fuzzy. With plotallvars = TRUE, a scatterplot matrix of all variables is drawn. With plotallvars = FALSE, only the two specified variables are plotted, with axis labels taken from the column names of data.

See Also

boot.kmeans, compare.clusters, bootk.hardsoftvis, kmeans, FKM

Examples

Run this code
set.seed(1)
x <- as.matrix(iris[, -5])

# run bootstrap kmeans
res <- boot.kmeans(data = x, groups = 3, iterations = 20)

# scatterplot matrix of all variables
bootk.hardsoftvis(x, res, TRUE)

# scatterplot matrix of variable 1 and variable 2
bootk.hardsoftvis(x, res, plotallvars = FALSE, var1 = 1, var2 = 2)

Run the code above in your browser using DataLab