Learn R Programming

dtwclust (version 2.1.1)

dtwclust-methods: Methods for dtwclust

Description

Methods associated with dtwclust-class objects.

Usage

## S3 method for class 'dtwclust':
show(object)

## S3 method for class 'dtwclust': update(object, ..., evaluate = TRUE)

## S3 method for class 'dtwclust': predict(object, newdata = NULL, ...)

## S3 method for class 'dtwclust,missing': plot(x, y, ..., clus = seq_len(x@k), labs.arg = NULL, show.centroids = TRUE, data = NULL, time = NULL, plot = TRUE, type = "dendrogram")

Arguments

object, x
An object of class dtwclust-class as returned by dtwclust.
...
Further arguments to pass to geom_line for the plotting of the cluster centers, or to plot.hclust. See details.
evaluate
Logical. Defaults to TRUE and evaluates the updated call, which will result in a new dtwclust object. Otherwise, it returns the unevaluated call.
newdata
New data to be evaluated. It can take any of the supported formats of dtwclust.
y
Ignored.
clus
A numeric vector indicating which clusters to plot.
labs.arg
Arguments to change the title and/or axis labels. See labs for more information
show.centroids
Logical flag. Should cluster centroids be included in the plots?
data
The data in the same format as it was provided to dtwclust.
time
Optional values for the time axis. If series have different lengths, provide the time values of the longest series.
plot
Logical flag. You can set this to FALSE in case you want to save the ggplot object without printing anything to screen
type
What to plot. Only relevant for hierarchical procedures. See details.

Value

  • The plot method returns a gg object (or NULL for hierarchical methods) invisibly.

Details

Supported generics from the flexclust package are: randIndex and clusterSim.

Show method displays basic information from the clustering results.

The update method takes the original function call, replaces any provided argument and optionally evaluates the call again. Use evaluate = FALSE if you want to get the unevaluated call.

The predict generic can take the usual newdata argument and it returns the cluster(s) to which the data belongs; if NULL, it simply returns the obtained cluster indices. It preprocesses the data with the corresponding function if available.

The plot method, by default, plots the time series of each cluster along with the obtained centroid. It uses ggplot2 plotting system (see ggplot). The default values for cluster centers are: linetype = "dashed", size = 1.5, colour = "black", alpha = 0.5. You can change this by means of ....

The flag save.data should be set to TRUE when running dtwclust to be able to use this. Optionally, you can manually provide the data in the data parameter.

The function returns the gg object invisibly, in case you want to modify it to your liking. You might want to look at ggplot_build if that's the case.

If a hierarchical procedure was used, then you can specify type = "dendrogram" to plot the corresponding dendrogram (the default in this case), and pass any extra parameters via .... Use type = "series" to plot the time series clusters using the original call's k.

See Also

dtwclust-class, dtwclust, ggplot