Learn R Programming

IMIFA (version 1.3.1)

plot.Results_IMIFA: Plotting output and parameters of inferential interest for IMIFA and related models

Description

Plotting output and parameters of inferential interest for IMIFA and related models

Usage

# S3 method for Results_IMIFA
plot(x = NULL, plot.meth = c("all", "correlation",
  "density", "errors", "GQ", "means", "parallel.coords", "trace", "zlabels"),
  param = c("means", "scores", "loadings", "uniquenesses", "pis", "alpha",
  "discount"), zlabels = NULL, heat.map = TRUE, palette = NULL,
  g = NULL, mat = TRUE, ind = NULL, fac = NULL, by.fac = FALSE,
  type = c("h", "n", "p", "l"), intervals = TRUE, partial = FALSE,
  titles = TRUE, transparency = 0.75, ...)

Arguments

x

An object of class "Results_IMIFA" generated by get_IMIFA_results.

plot.meth

The type of plot to be produced for the param of interest, where correlation refers to ACF/PACF plots, means refers to posterior means, density, trace and parallel.coords are self-explanatory. "all" in this case, the default, refers to trace, density, means, correlation. parallel.coords is only available when param is one of means, loadings or uniquenesses - note that this method applies a small amount of horizontal jitter to avoid overplotting. Special types of plots which don't require a param are GQ, for plotting the posterior summaries of the numbers of groups/factors, if available, zlabels for plotting clustering uncertainties if clustering has taken place (and, if available, the average similarity matrix, reorder according to the map labels) with or without the clustering labels being supplied via the zlabels argument), and errors for visualing the difference between the estimated and empirical covariance matrix/matrices.

param

The parameter of interest for any of the following plot.meth options: trace, density, means, correlation. The param must have been stored when mcmc_IMIFA was initially ran. Includes pis for methods where clustering takes place, and allows posterior inference on alpha and discount for the "IMFA" and "IMIFA" methods.

zlabels

The true labels can be supplied if they are known. If this is not supplied, the function uses the labels that were supplied, if any, to get_IMIFA_results. Only relevant when plot.meth = "zlabels".

heat.map

Switch which allows plotting posterior mean loadings or posterior mean scores as a heatmap, or else as something akin to link{plot(..., type="h")}. Only relevant if param = "loadings" (in which case the default is TRUE) or param = "scores" (in which case the default is FALSE). Heatmaps are produced with the aid of mat2cols and plot_cols.

palette

An optional colour palette to be supplied if overwriting the default palette set inside the function by viridis is desired.

g

Optional argument that allows specification of exactly which cluster the plot of interest is to be produced for. If not supplied, the user will be prompted to cycle through plots for all clusters. Also functions as an index for which plot to return when plot.meth is GQ or zlabels in much the same way.

mat

Logical indicating whether a matplot is produced (defaults to TRUE). If given as FALSE, ind is invoked.

ind

Either a single number indicating which variable to plot when param is one of means or uniquenesses, or which cluster to plot if param is pis. If scores are plotted, a vector of length two giving which observation and factor to plot; If loadings are plotted, a vector of length two giving which variable and factor to plot. Only relevant when mat or by.fac is FALSE.

fac

Optional argument that provides an alternative way to specify ind[2] when mat is FALSE and param is one of scores or loadings.

by.fac

Optionally allows (mat)plotting of scores and loadings by factor - i.e. observation(s) (scores) or variable(s) (loadings) for a given factor, respectively, controlled by ind or fac) when set to TRUE. Otherwise factor(s) are plotted for a given observation or variable when set to FALSE (the default), again controlled by ind or fac. Only relevant when param is one of scores or loadings.

type

The manner in which the plot is to be drawn, as per the type argument to plot.

intervals

Logical indicating whether credible intervals around the posterior mean(s) are to be plotted when is.element(plot.meth, c("all", "means")). Defaults to TRUE.

partial

Logical indicating whether plots of type "correlation" use the PACF. The default, FALSE, ensures the ACF is used. Only relevant when plot.meth = "all", otherwise both plots are produced when plot.meth = "correlation".

titles

Logical indicating whether default plot titles are to be used (TRUE), or suppressed (FALSE).

transparency

A factor in [0, 1] modifying the opacity for overplotted lines. Defaults to 0.75.

...

Other arguments typically passed to plot.

Value

The desired plot with appropriate output and summary statistics printed to the console screen.

References

Murphy, K., Gormley, I. C. and Viroli, C. (2017) Infinite Mixtures of Infinite Factor Analysers: Nonparametric Model-Based Clustering via Latent Gaussian Models, arXiv:1701.07010.

See Also

mcmc_IMIFA, get_IMIFA_results, mat2cols, plot_cols

Examples

Run this code
# NOT RUN {
# See the vignette associated with the package for more graphical examples:
# vignette("IMIFA", package = "IMIFA")

# data(olive)
# area     <- olive$area
# simIMIFA <- mcmc_IMIFA(olive, method="IMIFA")
# resIMIFA <- get_IMIFA_results(simIMIFA, z.avgsim=TRUE)

# Examine the posterior distribution(s) of the number(s) of clusters (G) &/or latent factors (Q)
# For the IM(I)FA and OM(I)FA methods, this also plots the trace of the active/non-empty clusters
# plot(resIMIFA, plot.meth="GQ")
# plot(resIMIFA, plot.meth="GQ", g=2)

# Plot clustering uncertainty (and, if available, the similarity matrix)
# plot(resIMIFA, plot.meth="zlabels", zlabels=area)

# Visualise empirical vs. estimated covariance error metrics
# plot(resIMIFA, plot.meth="errors")

# Look at the trace, density, posterior mean and correlation of various parameters of interest
# plot(resIMIFA, plot.meth="all", param="means", g=1)
# plot(resIMIFA, plot.meth="all", param="means", g=1, ind=2)
# plot(resIMIFA, plot.meth="all", param="scores")
# plot(resIMIFA, plot.meth="all", param="scores", by.fac=TRUE)
# plot(resIMIFA, plot.meth="all", param="loadings", g=1)
# plot(resIMIFA, plot.meth="all", param="loadings", g=1, heat.map=FALSE)
# plot(resIMIFA, plot.meth="parallel.coords", param="uniquenesses")
# plot(resIMIFA, plot.meth="all", param="pis", intervals=FALSE, partial=TRUE)
# plot(resIMIFA, plot.meth="all", param="alpha")
# }

Run the code above in your browser using DataLab