Learn R Programming

MoEClust (version 1.6.0)

MoE_Uncertainty: Plot Clustering Uncertainties

Description

Plots the clustering uncertainty for every observation from a fitted "MoEClust" model, including models with a noise component.

Usage

MoE_Uncertainty(res,
                type = c("barplot", "profile"),
                truth = NULL,
                decreasing = FALSE,
                col = c("cluster", "uncertain", "none"),
                rug1d = TRUE,
                ...)

Value

A plot showing the clustering uncertainty of each observation (sorted in increasing/decreasing order when type="profile"). The (unsorted) vector of uncertainties can also be returned invisibly. When truth is supplied, the indices of the misclassified observations are also invisibly returned.

Arguments

res

An object of class "MoEClust" generated by MoE_clust, or an object of class "MoECompare" generated by MoE_compare. Models with a noise component are facilitated here too.

type

The type of plot to be produced (defaults to "barplot"). The "profile" option instead displays uncertainties in increasing/decreasing order of magnitude (see decreasing).

truth

An optional argument giving the true classification of the data. When truth is supplied and type="barplot", misclassified observations are highlighted in a different colour, otherwise observations with uncertainty greater than 1/res$G are given in a different colour. When truth is supplied and type="profile", the uncertainty of misclassified observations is marked by vertical lines on the plot.

decreasing

A logical indicating whether uncertainties should be ordered in decreasing order (defaults to FALSE). Only relevant when type="profile".

col

Only relevant when truth=NULL. A character string indicating whether points should be coloured according to their "cluster"-memberships (the default) in res$classification, according to whether they exceed the threshold to be deemed "uncertain", or not at all ("none"). "cluster" is inadvisable when the number of clusters res$G is large.

rug1d

A logical which is relevant only when type="barplot" and res$d == 1, i.e. the model was fitted to univariate data. When rug1d=TRUE, the x-axis is given by the actual observations (indicated with a rug), otherwise the x-axis is given by the indices of the observations as per similar plots when res$d > 1.

...

Catches unused arguments.

Author

Keefe Murphy - <keefe.murphy@mu.ie>

Details

The y-axis of this plot runs from 0 to 1 - 1/res$G, with a horizontal line also drawn at 1/res$G. When type="barplot", uncertainties greater than this value are given a different colour when truth is not supplied, otherwise misclassified observations are given a different colour. Note, however, that \(G^{(0)}\) = res$G + 1 is used in place of res$G for models with a noise component.

See Also

MoE_clust, MoE_gpairs, plot.MoEClust

Examples

Run this code
data(ais)
res <- MoE_clust(ais[,3:7], gating= ~ sex, G=3, modelNames="EEE", network.data=ais)

# Produce an uncertainty barplot
MoE_Uncertainty(res)

# Change the colour scheme
MoE_Uncertainty(res, col="uncertain")

# Produce an uncertainty profile plot
MoE_Uncertainty(res, type="profile")

# Let's assume the true clusters correspond to sex
(ub <- MoE_Uncertainty(res, truth=ais$sex))
(up <- MoE_Uncertainty(res, type="profile", truth=ais$sex))

# Examine the effect of rug1d for univariate models
mod <- MoE_clust(CO2data$CO2, expert=~GNP, G=2, modelNames="V", network.data=CO2data)
MoE_Uncertainty(mod, rug1d=FALSE)
MoE_Uncertainty(mod)

Run the code above in your browser using DataLab