1

I have a single time series where you can clearly see a process change (denoted by the manually drawn lines). I am trying to detect and cluster these changes so that I can be notified when a new cluster is beginning. I have already attempted K-means clustering, agglomerative clustering and they do a decent job but do not seem to cluster based on time, only the value. I expect to have 6 clusters in the timeseries. You can see the algorithm typically ignores time. Manual clustering Clustering attempt

I have googled a lot and discovered DTW however every article I read is comparing multiple time series instead of detecting changes within a single time series.

Does anyone have any references I can read up on this or have any solutions?

I am unable to provide actual data however here is some example data that you can use:

library(tidyverse)
example_data <- tibble(
  date_seq = 1:300,
  value = c(
    rnorm(65, .1, .1), 
    rnorm(65, -.25, .1),
    rnorm(20, 4, .25),
    rnorm(80, -.25, .1),
    rnorm(20, 4, .25),
    rnorm(50, 0, .1)
  )
)

Thank you!

jackbio
  • 131
  • 7
  • Please provide code to reproduce your dataset and desired results. In it's current form, this question isn't a good fit for Stack Overflow. (See https://stackoverflow.com/questions/5963269/) . Outside of that, I'd recommend doing some research into the set of algorithms referred to as "change point detection" - there are a number of R packages with various implementations - I've used the `changepoint` package in the past, but this post shows some other options to consider: https://lindeloev.github.io/mcp/articles/packages.html – Matt Summersgill Feb 25 '22 at 18:06

1 Answers1

0

I needed to solve a problem similar to yours. However, I used Markov to identify regime change moments instead of opting for a clustering method.

Here are good articles about it:

[RPubs by Majeed Simaan] [https://rpubs.com/simaan84/regime_switching]

[R-bloggers by Andrej Pivcevic] [https://www.r-bloggers.com/2019/02/switching-regressions-cluster-time-series-data-and-understand-your-development/]

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/31598821) – Martin Gal Apr 22 '22 at 13:50