Specify time series clustering via dtwclust

lcMethodDtwclust(
  response,
  time = getOption("latrend.time"),
  id = getOption("latrend.id"),
  nClusters = 2,
  ...
)

Arguments

response

The name of the response variable.

time

The name of the time variable.

id

The name of the trajectory identifier variable.

nClusters

Number of clusters.

...

Arguments passed to dtwclust::tsclust. The following arguments are ignored: series, k, trace.

References

Sardá-Espinosa A (2019). “Time-Series Clustering in R Using the dtwclust Package.” The R Journal. doi:10.32614/RJ-2019-023 .

Examples

data(latrendData)

if (require("dtwclust")) {
  method <- lcMethodDtwclust("Y", id = "Id", time = "Time", nClusters = 3)
  model <- latrend(method, latrendData)
}
#> Loading required package: dtwclust
#> Loading required package: proxy
#> 
#> Attaching package: ‘proxy’
#> The following objects are masked from ‘package:stats’:
#> 
#>     as.dist, dist
#> The following object is masked from ‘package:base’:
#> 
#>     as.matrix
#> Loading required package: dtw
#> Loaded dtw v1.23-1. See ?dtw for help, citation("dtw") for use in publication.
#> dtwclust:
#> Setting random number generator to L'Ecuyer-CMRG (see RNGkind()).
#> To read the included vignettes type: browseVignettes("dtwclust").
#> See news(package = "dtwclust") after package updates.
#> 
#> 	Precomputing distance matrix...
#> 
#> Iteration 1: Changes / Distsum = 200 / 582.2736
#> Iteration 2: Changes / Distsum = 42 / 416.7195
#> Iteration 3: Changes / Distsum = 16 / 364.8345
#> Iteration 4: Changes / Distsum = 9 / 354.0672
#> Iteration 5: Changes / Distsum = 4 / 348.6416
#> Iteration 6: Changes / Distsum = 0 / 348.6416
#> 
#> 	Elapsed time is 0.105 seconds.
#>