View source: R/Plotting_Functions.R
MoE_gpairs | R Documentation |
Produces a matrix of plots showing pairwise relationships between continuous response variables and continuous/categorical/logical/ordinal associated covariates, as well as the clustering achieved, according to fitted MoEClust mixture models.
MoE_gpairs(res,
response.type = c("points", "uncertainty", "density"),
subset = list(...),
scatter.type = c("lm", "points"),
conditional = c("stripplot", "boxplot"),
addEllipses = c("outer", "yes", "no", "inner", "both"),
expert.covar = TRUE,
border.col = c("purple", "black", "brown", "brown", "navy"),
bg.col = c("cornsilk", "white", "palegoldenrod", "palegoldenrod", "cornsilk"),
outer.margins = list(bottom = grid::unit(2, "lines"),
left = grid::unit(2, "lines"),
top = grid::unit(2, "lines"),
right = grid::unit(2, "lines")),
outer.labels = NULL,
outer.rot = c(0, 90),
gap = 0.05,
buffer = 0.025,
uncert.cov = FALSE,
scatter.pars = list(...),
density.pars = list(...),
stripplot.pars = list(...),
boxplot.pars = list(...),
barcode.pars = list(...),
mosaic.pars = list(...),
axis.pars = list(...),
diag.pars = list(...),
...)
res |
An object of class |
response.type |
The type of plot desired for the scatterplots comparing continuous response variables. Defaults to Points can also be sized according to their associated clustering uncertainty with the option Alternatively, the bivariate |
subset |
A list giving named arguments for producing only a subset of panels:
The result of the subsetting must include at least two variables, whether they be the MAP classification, a response variable, or a covariate, in order to be valid for plotting purposes. The arguments |
scatter.type |
A vector of length 2 (or 1) giving the plot type for the upper and lower triangular portions of the plot, respectively, pertaining to the associated covariates. Defaults to |
conditional |
A vector of length 2 (or 1) giving the plot type for the upper and lower triangular portions of the plot, respectively, for plots involving a mix of categorical and continuous variables. Defaults to All |
addEllipses |
Controls whether to add MVN ellipses with axes corresponding to the within-cluster covariances for the response data. The options Ellipses are centered on the posterior mean of the fitted values when there are expert network covariates, otherwise on the posterior mean of the response variables. In the presence of expert network covariates, the component-specific covariance matrices are also (by default, via the argument |
expert.covar |
Logical (defaults to |
border.col |
A vector of length 5 (or 1) containing border colours for plots against the MAP classification, response vs. response, covariate vs. response, response vs. covariate, and covariate vs. covariate panels, respectively. Defaults to |
bg.col |
A vector of length 5 (or 1) containing background colours for plots against the MAP classification, response vs. response, covariate vs. response, response vs. covariate, and covariate vs. covariate panels, respectively. Defaults to |
outer.margins |
A list of length 4 with units as components named bottom, left, top, and right, giving the outer margins; the defaults uses two lines of text. A vector of length 4 with units (ordered properly) will work, as will a vector of length 4 with numeric variables (interpreted as lines). |
outer.labels |
The default is |
outer.rot |
A 2-vector ( |
gap |
The gap between the tiles; defaulting to |
buffer |
The fraction by which to expand the range of quantitative variables to provide plots that will not truncate plotting symbols. Defaults to |
uncert.cov |
A logical indicating whether the expansion factor for points on plots involving covariates should also be modified when |
scatter.pars |
A list supplying select parameters for the continuous vs. continuous scatterplots.
list(scat.pch=res$classification, uncert.pch=19, scat.col=res$classification, scat.size=unit(0.25, "char"), eci.col=1:res$G, noise.size=unit(0.2, "char")), where Note also that |
density.pars |
A list supplying select parameters for visualising the bivariate density contours, only when
list(grid.size=c(100, 100), dcol="grey50", nlevels=11, show.labels=TRUE, label.style="mixed"), where |
stripplot.pars |
A list supplying select parameters for continuous vs. categorical panels when one or both of the entries of
list(strip.pch=res$classification, strip.size=unit(0.5, "char"), strip.col=res$classification, jitter=TRUE, size.noise=unit(0.4, "char")), where |
boxplot.pars |
A list supplying select parameters for continuous vs. categorical panels when one or both of the entries of
list(box.pch="|", box.col="black", varwidth=FALSE, notch=FALSE, notch.frac=0.5, box.fill=1:res$G). All of the above are relevant for |
barcode.pars |
A list supplying select parameters for continuous vs. categorical panels when one or both of the entries of
list(bar.col=res$G:1, nint=0, ptsize=unit(0.25, "char"), ptpch=1, bcspace=NULL, use.points=FALSE), where |
mosaic.pars |
A list supplying select parameters for categorical vs. categorical panels (if any).
list(shade=NULL, gp_labels=grid::gpar(fontsize=9), gp_args=list(), gp=list(), mfill=TRUE, mcol=1:res$G). The current default arguments and values thereof are passed through to |
axis.pars |
A list supplying select parameters for controlling the axes.
list(n.ticks=5, axis.fontsize=9). The argument |
diag.pars |
A list supplying select parameters for panels along the diagonal.
list(diag.fontsize=9, show.hist=TRUE, show.dens=FALSE, diagonal=TRUE, hist.color=hist.color, show.counts=TRUE), where The argument When |
... |
Catches unused arguments. Alternatively, named arguments can be passed directly here to any/all of |
A generalised pairs plot showing all pairwise relationships between clustered response variables and associated gating &/or expert network continuous &/or categorical variables, coloured according to the MAP classification, with the marginal distributions of each variable along the diagonal.
For MoEClust
models with more than one expert network covariate, fitted lines produced in continuous covariate vs. continuous response scatterplots via scatter.type="lm"
or scatter.type="ci"
will NOT correspond to the coefficients in the expert network (res$expert
).
plot.MoEClust
is a wrapper to MoE_gpairs
which accepts the default arguments, and also produces other types of plots. Caution is advised producing generalised pairs plots when the dimension of the data is large.
Finally, note that all colour-related defaults in scatter.pars
, stripplot.pars
, barcode.pars
, and mosaic.pars
above assume a specific colour-palette (see mclust.options("classPlotColors")
). Thus, for instance, specifying scatter.pars$scat.col=res$classification
will produce different results compared to leaving this argument unspecified. This is especially true for models with a noise component, for which the default is handled quite differently (for one thing, res$G
is the number of non-noise components). Similarly, all pch
-related defaults in scatter.pars
and stripplot.pars
above assume a specific set of plotting symbols also (see mclust.options("classPlotSymbols")
). Generally, all colour and symbol related arguments are strongly recommended to be left at their default values, unless being supplied as a single character string, e.g. "black"
for colours. To help in this regard, colour-related arguments sensibly inherent their default from scatter.pars$scat.col
if that is supplied and the argument in question is not.
Keefe Murphy - <keefe.murphy@mu.ie>
Murphy, K. and Murphy, T. B. (2020). Gaussian parsimonious clustering models with covariates and a noise component. Advances in Data Analysis and Classification, 14(2): 293-325. <\Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s11634-019-00373-8")}>.
Emerson, J. W., Green, W. A., Schloerke, B., Crowley, J., Cook, D., Hofmann, H. and Wickham, H. (2013). The generalized pairs plot. Journal of Computational and Graphical Statistics, 22(1): 79-91.
MoE_clust
, MoE_stepwise
, plot.MoEClust
, MoE_Uncertainty
, expert_covar
, panel.stripplot
, panel.bwplot
, panel.violin
, strucplot
, mclust.options
data(ais)
res <- MoE_clust(ais[,3:7], G=2, gating= ~ BMI, expert= ~ sex,
network.data=ais, modelNames="EVE")
MoE_gpairs(res)
# Produce the same plot, but with a violin plot in the lower triangle.
# Colour the outline of the mosaic tiles rather than the interior using mfill.
# Size points in the response vs. response panels by their clustering uncertainty.
MoE_gpairs(res, conditional=c("stripplot", "violin"),
mfill=FALSE, response.type="uncertainty")
# Instead show the bivariate density contours of the response variables (without labels).
# (Plotting may be slow when response.type="density" for models with expert covariates.)
# Use different colours for histograms of covariates in the gating/expert/both networks.
# Also use different colours for response vs. covariate & covariate vs. response panels.
MoE_gpairs(res, response.type="density", show.labels=FALSE,
hist.color=c("black", "cyan", "hotpink", "chartreuse"),
bg.col=c("whitesmoke", "white", "mintcream", "mintcream", "floralwhite"))
# Examine the effect of the expert.covar argument in conjunction with show.dens
MoE_gpairs(res, cov.ind=0, expert.covar=TRUE,
show.dens=TRUE, show.hist=FALSE, grid.size=1000)
MoE_gpairs(res, cov.ind=0, expert.covar=FALSE,
show.dens=TRUE, show.hist=FALSE, grid.size=1000)
# Produce a generalised pairs plot for a model with a noise component.
# Reorder the covariates and omit the variables "Hc" and "Hg".
# Use barcode plots for the categorical/continuous pairs.
# Magnify the size of scatter points assigned to the noise component.
resN <- MoE_clust(ais[,3:7], G=2, gating= ~ SSF + Ht, expert= ~ sex,
network.data=ais, modelNames="EEE", tau0=0.1, noise.gate=FALSE)
MoE_gpairs(resN, data.ind=c(1,2,5), cov.ind=c(3,1,2),
conditional="barcode", noise.size=grid::unit(0.5, "char"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.