plot.MEDseq | R Documentation |
Produces a range of plots of the results of fitted MEDseq
models.
## S3 method for class 'MEDseq'
plot(x,
type = c("clusters", "central", "precision", "gating",
"bic", "icl", "aic", "dbs", "asw", "cv",
"nec", "LOGLIK", "dbsvals", "aswvals", "similarity",
"uncert.bar", "uncert.profile", "loglik",
"d", "dH", "f", "Ht", "i", "I", "ms", "mt"),
seriated = c("observations", "both", "clusters", "none"),
soft = NULL,
weighted = TRUE,
SPS = NULL,
smeth = "TSP",
sortv = NULL,
subset = NULL,
quant.scale = NULL,
...)
x |
An object of class |
type |
A character string giving the type of plot requested:
Also available are the following options which act as wrappers to types of plots produced by the Note also that all of the plot types below can be made to either work with the hard MAP partition (as per
|
seriated |
Switch indicating whether seriation should be used to improve the visualisation by re-ordering the The Additionally, the Though all |
soft |
This argument is a single logical indicator which is only relevant for the Note that soft cluster membership probabilities will not be available if Additionally, for these plots and the |
weighted |
This argument is a single logical indicator which is only relevant for the Additionally, for these plots and the |
SPS |
A logical indicating whether clusters should be labelled according to the state-permanence-sequence representation of their central sequence. See |
smeth |
A character string with the name of the seriation method to be used. Defaults to |
sortv |
A sorting method governing the ordering of observations for Additionally, when (and only when) |
subset |
An optional numeric vector giving the indices of the clusters to be plotted. For models with a noise component, values in |
quant.scale |
Logical indicating whether precision parameter heatmaps should use quantiles to determine non-linear colour break-points when |
... |
Catches unused arguments, and allows arguments to Also allows select additional arguments to the TraMineR function For the plot types borrowed from TraMineR, select additional generic graphical parameters can also be supplied (see |
The type
options related to model selection criteria ("bic"
through to "nec"
) and "LOGLIK"
plot values for all fitted models in the "MEDseq"
object x
. The remaining type
options plot results for the optimal model, by default. However, arguments to get_MEDseq_results
can be passed via the ...
construct to plot corresponding results for suboptimal models in x
when type
is one of "clusters"
, "d"
, "dH"
, "f"
, "Ht"
, "i"
, "I"
, "ms"
, or "mt"
. See the examples below.
The visualisation according to type
of the results of a fitted MEDseq
model.
Every type
of plot respects the sampling weights, if any. However, those related to seqplot
plots from TraMineR ("d"
, "dH"
, "f"
, "Ht"
, "i"
, "I"
, "ms"
, "mt"
) do so only when weighted=TRUE
(the default). Further customisation of such plots is possible via the ...
construct.
For these plot types borrowed from TraMineR, when weighted=TRUE
, the y-axis labels (which can be suppressed using ylab=NA
) display cluster sizes which correspond to the output of MEDseq_meantime(x, MAP=!soft, weighted=weighted, map.size=!soft, wt.size=weighted)
when size=TRUE
is passed via ...
. The defaults of soft=TRUE
and weighted=TRUE
imply defaults of MAP=FALSE
, weighted=TRUE
, map.size=FALSE
, and wt.size=TRUE
, where wt.size=TRUE
is NOT the default behaviour for MEDseq_meantime
.
The plot types borrowed from TraMineR may be too tall/wide to display in the preview panel. This can lead to error messages about figure margins being too large and the graphics state being invalid. The same may also be true when type
is "dbsvals"
or "aswvals"
.
Keefe Murphy - <keefe.murphy@mu.ie>
Murphy, K., Murphy, T. B., Piccarreta, R., and Gormley, I. C. (2021). Clustering longitudinal life-course sequences using mixtures of exponential-distance models. Journal of the Royal Statistical Society: Series A (Statistics in Society), 184(4): 1414-1451. <\Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/rssa.12712")}>.
Studer, M. (2018). Divisive property-based and fuzzy clustering for sequence analysis. In G. Ritschard and M. Studer (Eds.), Sequence Analysis and Related Approaches: Innovative Methods and Applications, Volume 10 of Life Course Research and Social Policies, pp. 223-239. Cham, Switzerland: Springer.
Gabadinho, A., Ritschard, G., Mueller, N. S., and Studer, M. (2011). Analyzing and visualizing state sequences in R with TraMineR. Journal of Statistical Software, 40(4): 1-37.
MEDseq_fit
, seqplot
, dbs
, get_MEDseq_results
, seriate
, list_seriation_methods
, fuzzyseqplot
, MEDseq_meantime
, MEDseq_clustnames
, seqformat
, MEDseq_compare
, MEDseq_control
# Load the MVAD data
data(mvad)
mvad$Location <- factor(apply(mvad[,5:9], 1L, function(x)
which(x == "yes")), labels = colnames(mvad[,5:9]))
mvad <- list(covariates = mvad[c(3:4,10:14,87)],
sequences = mvad[,15:86],
weights = mvad[,2])
mvad.cov <- mvad$covariates
# Create a state sequence object with the first two (summer) time points removed
states <- c("EM", "FE", "HE", "JL", "SC", "TR")
labels <- c("Employment", "Further Education", "Higher Education",
"Joblessness", "School", "Training")
mvad.seq <- seqdef(mvad$sequences[-c(1,2)], states=states, labels=labels)
# Fit a range of exponential-distance models without clustering
mod0 <- MEDseq_fit(mvad.seq, G=1)
# Show the central sequence and precision parameters of the optimal model
plot(mod0, type="central")
plot(mod0, type="ms")
plot(mod0, type="precision")
# Fit a range of unweighted mixture models without covariates
# Only consider models with a noise component
# mod1 <- MEDseq_fit(mvad.seq, G=9:11, modtype=c("CCN", "CUN", "UCN", "UUN"))
# Plot the DBS values for all fitted models
# plot(mod1, "dbs") #equivalent to plot(mod1$DBS)
# Plot the clusters of the optimal model (according to the dbs criterion)
# plot(mod1, "clusters", criterion="dbs")
# Use seriation to order the observations and the clusters
# plot(mod1, "clusters", criterion="dbs", seriated="both")
# Use a different seriation method
# seriation::list_seriation_methods("dist")
# plot(mod1, "clusters", criterion="dbs", seriated="both", smeth="Spectral")
# Use the DBS values instead to sort the observations, and label the clusters
# plot(mod1, "clusters", criterion="dbs", seriated="both", sortv="dbs", SPS=TRUE, size=TRUE)
# Plot the observation-specific ASW values of the best CCN model (according to the asw criterion)
# plot(mod1, "aswvals", modtype="CCN", criterion="asw")
# Plot the similarity matrix (as a heatmap) of the best G=9 model (according to the icl criterion)
# plot(mod1, "similarity", G=9, criterion="icl")
# Fit a model with weights and gating covariates
# mod2 <- MEDseq_fit(mvad.seq, G=10, modtype="UCN", weights=mvad$weights,
# gating=~ fmpr + gcse5eq + livboth, covars=mvad.cov)
# Plot the central sequences & precision parameters of this model
# plot(mod2, "central")
# plot(mod2, "precision")
# Plot the clustering uncertainties in the form of a barplot
# plot(mod2, "uncert.bar")
# Plot the observation-specific DBS values
# plot(mod2, "dbsvals")
# Plot the transversal entropies by cluster & then the state-distributions by cluster
# Note that these plots may not display properly in the preview panel
# plot(mod2, "Ht", ylab=NA) # suppress the y-axis labels
# plot(mod2, "d", border=TRUE) # add borders
# plot(mod2, "dH", col.entr="brown", # add colour
# ylab=NA, border=TRUE) # both simultaneously
# The plots above use the soft cluster membership probabilities
# Discard this information and reproduce the per-cluster state-distributions plot
# plot(mod2, "d", soft=FALSE)
# The plots above use the observation-specific sampling weights
# Discard this information and plot the mean times per state per cluster
# plot(mod2, "mt", weighted=FALSE)
# Use subset to show the "fake" modal sequence for the noise component
# plot(mod2, "ms")
# plot(mod2, "ms", subset=0:mod2$G)
# Use type="I" and subset=0 to examine the noise component, with additional legend arguments
# plot(mod2, "I", subset=0, border=TRUE, weighted=FALSE,
# seriated="none", bty="n", cex.legend=0.75)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.