- x
An object of class "MEDseq"
generated by MEDseq_fit
or an object of class "MEDseqCompare"
generated by MEDseq_compare
.
- type
A character string giving the type of plot requested:
"clusters"
Visualise the data set with sequences grouped into their respective clusters. See seriated
. Similar to the type="I"
plot (see below). However, type="clusters"
always plots the hard MAP partition and is unaffected by the soft
argument below.
"central"
Visualise the central sequences (typically modal sequences, but this depends on the opti
argument to MEDseq_control
used during model-fitting). See seriated
. The central sequence for the noise component, if any, is not shown as it doesn't contribute in any way to the likelihood. See the type="ms"
option below for an alternative means of displaying the central sequences.
"precision"
Visualise the precision parameters in the form of a heatmap. Values of 0
and Inf
are shown in "white"
and "black"
respectively (see quant.scale
and seriated
).
"gating"
Visualise the gating network, i.e. the observation index (by default) against the mixing proportions for that observation, coloured by cluster. Such plots can be produced with or without the gating network actually having had covariates included during model-fitting. See seriated
, but note that this argument is only relevant for models with gating network covariates, provided x.axis
is not supplied. The optional argument x.axis
can be passed via the ...
construct to change the x-axis against which mixing proportions are plotted (only advisable for models with a single gating network covariate, when x.axis
is a quantity related to the gating network of the fitted model).
"bic"
Plots all BIC values in a fitted MEDseq
object.
"icl"
Plots all ICL values in a fitted MEDseq
object.
"aic"
Plots all AIC values in a fitted MEDseq
object.
"dbs"
Plots all (weighted) mean/median DBS criterion values in a fitted MEDseq
object.
"asw"
Plots all (weighted) mean/median ASW criterion values in a fitted MEDseq
object.
"cv"
Plots all cross-validated log-likelihood values in a fitted MEDseq
object.
"nec"
Plots all NEC values in a fitted MEDseq
object.
"LOGLIK"
Plots all maximal log-likelihood values in a fitted MEDseq
object. While the type
options above, from "bic"
though to "nec"
, can be used as model selection criteria in MEDseq_compare
and via MEDseq_control
in MEDseq_fit
, "LOGLIK"
cannot.
"dbsvals"
Silhouette plot using observations-specific DBS values for the optimal model (coloured by cluster). See seriated
.
"aswvals"
Silhouette plot using observations-specific ASW values for the optimal model (coloured by cluster). See seriated
.
"similarity"
Produces a heatmap of the similarity matrix constructed from the x$z
matrix at convergence, with observations reordered via seriated
for visual clarity. The (potentially seriated
) similarity matrix can also be invisibly returned.
"uncert.bar"
Plot the observation-specific clustering uncertainties, if any, in the form of a bar plot. Different colours will be used to distinguish observations whose uncertainty exceeds the threshold 1/x$G
.
"uncert.profile"
Plot the observation-specific clustering uncertainties, if any, in the form of a profile plot.
"loglik"
Plot the log-likelihood at every iteration of the EM/CEM algorithm used to fit the model.
Also available are the following options which act as wrappers to types of plots produced by the seqplot
function in the TraMineR package. All are affected by the value of seriated
and all account for the sampling weights (if any) by default (see the weighted
argument and the related Note
below).
Note also that all of the plot types below can be made to either work with the hard MAP partition (as per seqplot
), or to use the soft cluster membership probabilities, via the soft
argument below. The soft information is used by default for all but the "i"
and "I"
plot types, which (by default) discard this information to instead use the MAP partition: see the soft
argument below for modifying this default behaviour for all of the following plot types.
"d"
State distribution plots (chronograms, by cluster).
"dH"
State distribution plots (chronograms, by cluster) with overlaid entropy line as per type="Ht"
.
"f"
Sequence frequency plots (by cluster).
"Ht"
Transversal entropy plots (by cluster).
"i"
Selected sequence index plots (by cluster). By default, bar widths for each observation will be proportional to their weight (if any). However, this can be overruled by specifying weighted=FALSE
.
"I"
Whole set index plots (by cluster). This plot effectively contains almost exactly the same information as type="clusters"
plots, and is similarly affected by the seriated
argument, albeit shown on a by-cluster basis rather than stacked in one plot. However, bar widths for each observation will (by default) be proportional to their weight (if any), which is not the case for type="clusters"
plots. However, this can be overruled by specifying weighted=FALSE
.
"ms"
Modal state sequence plots (by cluster). This is an alternative way of displaying the central sequences beyond the type="central"
option above. Notably, this option respects arguments passed to get_MEDseq_results
via the ...
construct (see below), while type="central"
does not. Note: unlike type="central"
, this option always plots modal sequences, even if another opti
setting was invoked during model-fitting via MEDseq_control
, in which case there may be a mismatch between the visualisation and x$params$theta
. Also, like type="central"
, nothing is shown for the noise component by default. However, it can be shown here by specifying subset
appropriately (see below), despite modal sequence for noise components not actually being estimated by the model.
"mt"
Mean times plots (by cluster). This is equivalent to plotting the results of MEDseq_meantime(x, MAP=!soft, weighted=weighted, norm=TRUE, prop=FALSE, map.size=!soft, wt.size=weighted)
. Other options, particularly for norm=FALSE
and prop=TRUE
, may be added in future versions of this package. By default, bar labels taken from a suitable call to MEDseq_meantime
are included, but these can be suppressed by specifying bar.labels=FALSE
(see below).
seriated
Switch indicating whether seriation should be used to improve the visualisation by re-ordering the "observations"
within clusters (the default), the "clusters"
, "both"
, or "none"
. See seriate
and the smeth
and sortv
arguments below.
The "clusters"
option (and the cluster-related part of "both"
) is only invoked when type
is one of "clusters"
, "central"
, "precision"
, "gating"
, "dbsvals"
, "aswvals"
, "similarity"
, "d"
, "dH"
, "f"
, "Ht"
, "i"
, "I"
, "ms"
, or "mt"
and the model has more than one component.
Additionally, the "observations"
option (and the observation-related part of "both"
) is only invoked when type
is one of "clusters"
, "gating"
, "similarity"
, "i"
or "I"
, which are also the only options for which "both"
is relevant.
Though all seriated
options can be specified when type
is "gating"
, they are only invoked and relevant when the model actually contains gating network covariates and x.axis
is not supplied via the ...
construct.
soft
This argument is a single logical indicator which is only relevant for the "clusters"
, "central"
, and "precision"
plot types, as well as the "d"
, "dH"
, "f"
, "Ht"
, "i"
, "I"
, "ms"
, and "mt"
plot types borrowed from TraMineR. For plots borrowed from TraMineR, when soft=TRUE
(the default for all but the "i"
and "I"
type
plots) the soft cluster membership probabilities are used in a manner akin to fuzzyseqplot
. Otherwise, when FALSE
(the default for "i"
and "I"
type
plots), the soft information is discarded and the hard MAP partition is used instead.
Note that soft cluster membership probabilities will not be available if x$G=1
or the model was fitted using the algo="CEM"
option to MEDseq_control
. Plots may still be weighted when soft
is FALSE
, according to the observation-specific sampling weights, when weighted=TRUE
, and both arguments can also be simultaneously TRUE
. Note also that type="Ht"
can be used in conjunction with soft=TRUE
, unlike fuzzyseqplot
for which type="Ht"
is not permissible. Finally, be advised that plotting may be time-consuming when soft=TRUE
for "i"
and "I"
type
plots.
Additionally, for these plots and the "clusters"
, "central"
, and "precision"
types, soft
is passed through to MEDseq_clustnames
in the rare case where SPS=TRUE
(see below) and the optional MEDseq_clustnames
argument size=TRUE
is invoked (again, see below). Note that soft=TRUE
here corresponds to MAP=FALSE
in MEDseq_clustnames
.
weighted
This argument is a single logical indicator which is only relevant for the "clusters"
, "central"
, and "precision"
plot types, as well as the "d"
, "dH"
, "f"
, "Ht"
, "i"
, "I"
, "ms"
, and "mt"
plot types borrowed from TraMineR. For plots borrowed from TraMineR, when TRUE
(the default), the weights (if any) are accounted for in such plots. Note that when soft
is TRUE
, plots will still be weighted according to the soft cluster membership probabilities; thus weighted=TRUE
and soft=TRUE
allows both these and the observation-specific weights to be used simultaneously (the default behaviour for both arguments).
Additionally, for these plots and the "clusters"
, "central"
, and "precision"
types, weighted
is passed through to MEDseq_clustnames
in the rare case where SPS=TRUE
(see below) and the optional MEDseq_clustnames
argument size=TRUE
is invoked (again, see below).
SPS
A logical indicating whether clusters should be labelled according to the state-permanence-sequence representation of their central sequence. See MEDseq_clustnames
and seqformat
. Defaults to TRUE
for the plot types adapted from TraMineR, i.e. the "d"
, "dH"
, "f"
, "Ht"
, "i"
, "I"
, "ms"
, and "mt"
type
plots. The SPS
argument is also relevant for the following type
plots: "clusters"
, "central"
, and "precision"
, though SPS
defaults to FALSE
in those instances. Note that if SPS=TRUE
for any relevant plot type, the soft
and weighted
arguments above are relevant if the optional MEDseq_clustnames
argument size=TRUE
is invoked (see below).
smeth
A character string with the name of the seriation method to be used. Defaults to "TSP"
. See seriate
and seriation::list_seriation_methods("dist")
for further details and the available methods. Only relevant when seriated != "none"
. When seriated == "obs"
or seriated == "both"
, the ordering of observations can be governed by smeth
or instead governed by the sortv
argument below, but the ordering of clusters (when seriated="clusters"
or seriated="both"
) is always governed by smeth
.
sortv
A sorting method governing the ordering of observations for "clusters"
, "gating"
, "similarity"
, "i"
, or "I"
type
plots. Potential options include "dbs"
and "asw"
, for sorting observations by their DBS or ASW values (if available), as well as "from.start"
and "from.end"
(only when type
is "clusters"
, "i"
, or "I"
), under which sequences are sorted by the elements of the alphabet at the successive positions starting from the start/end of the sequences (as per TraMineR). Only relevant if seriated
is one of "observations"
or "both"
. Note that the sortv
argument overrides the setting in smeth
as it pertains to the ordering of observations if sortv
is supplied; otherwise sortv
is NULL
and smeth
is invoked. Note that smeth
always dictates the ordering of clusters (i.e. when seriated="clusters"
or seriated="both"
).
Additionally, when (and only when) soft=TRUE
and type="I"
, the additional option sortv="membership"
is provided in accordance with fuzzyseqplot
, on which such plots are based.
subset
An optional numeric vector giving the indices of the clusters to be plotted. For models with a noise component, values in 0:x$G
are admissible, where 0
and x$G
can both denote the noise component, otherwise only values in 1:x$G
. Only relevant for the TraMineR-type
plots, i.e. "d"
, "dH"
, "f"
, "Ht"
, "i"
, "I"
, "ms"
, and "mt"
type
plots. Note however, that noise components are not plotted by default for type="ms"
plots as the noise component's modal sequence is not estimated by the model, so subset
must be explicitly specified appropriately should you wish to see it.
quant.scale
Logical indicating whether precision parameter heatmaps should use quantiles to determine non-linear colour break-points when type="precision"
. This ensures each colour represents an equal proportion of the data. The behaviour of 0
or Inf
values remains unchanged; only strictly-positive finite entries are affected. Heavily imbalanced values are more likely for the "UU"
and "UUN"
model types, thus quant.scale
defaults to TRUE
in those instances and FALSE
otherwise. Note that quant.scale
is always FALSE
for the "CC"
and "CCN"
model types.
...
Catches unused arguments, and allows arguments to get_MEDseq_results
to be passed when type
is one of "clusters"
, "dbsvals"
, "aswvals"
, "similarity"
, "uncert.bar"
, "uncert.profile"
, "d"
, "dH"
, "f"
, "Ht"
, "i"
, "I"
, "ms"
, or "mt"
, as well as the x.axis
argument when type="gating"
.
Also allows select additional arguments to the TraMineR function seqplot
(and the functions it calls in turn) to be used for the relevant plot types (e.g. border
, col
, yaxis
/xaxis
and/or ylab
/xlab
, pbarw
when type="f"
, serr
and bar.labels
(as a logical only) when type="mt"
, col.entr
when type="dH"
or type="Ht"
(with respective implied defaults of "black"
and "blue"
), and info
when type="ms"
).
For the plot types borrowed from TraMineR, select additional generic graphical parameters can also be supplied (see par
, barplot
, and legend
). Finally, the cluster
and size
arguments to MEDseq_clustnames
can be supplied where relevant, i.e. for the plot types borrowed from TraMineR or when type
is one of "clusters"
, "central"
, or "precision"
.