I'm working with temporal simulations (forward in time) and I would like to find the best way to detect the two major change points in this time series.

I have several replicates of the same simulation, then my idea was to collect the two change points identified for each replicate and average 1) the first change point among replicates; and 2) the second change point among replicates.

I found the package tsoutliers but does not find what I would expect.

This is an example of one replicate. The data are not continuous in the sense that I'm collecting data with an interval time of 50.


dat.ts<- ts(data,frequency=1)
data.ts.outliers <- tso(dat.ts, types = c("AO", "LS", "TC"))

Do you have any suggestion on which method would be the best?

The other option I was considering is to obtain the mean and variance for each time point and make pairwise statistical test for consecutive time points.


1 Answer 1


My first suggestion would be to use a package for changepoint analysis rather than outlier detection. An example would be the changepoint package in R. Here is the code for the analysis of the above data:


The mean and variance of your data is changing so it makes sense to use the cpt.meanvar function.

In terms of a multivariate comparison, I would advise using a multivariate changepoint detection approach. If you want the changes in the same place in all series then you can use the InspectChangepoint R package which appears to work well.

  • $\begingroup$ I followed your suggestion and I used cpt.meanvar. It find TWO change points, corresponding to the points where I see big differences. I tried to use also the InspectChangepoint R package, but it did not work as good. It finds a lot change points. To overcome this issue my idea was to run cpt.meanvar() on each replicate independently and then average the time value of each change point. At the end I have an average of the first change point (value 1) and an average of the second change point (value 2). What do you think? $\endgroup$ Aug 31, 2017 at 17:23
  • $\begingroup$ It is unfortunate that the InspectChangepoint package didn't work out of the box, have you tried changing the lambda value to be larger? As lambda increases you get less changes. You also might want to set M=100 or something similar as M=0 is the default which uses the Binary Segmentation algorithm whereas M>0 uses the Wild Binary Segmentation algorithm which is preferred. $\endgroup$
    – adunaic
    Sep 2, 2017 at 18:32
  • $\begingroup$ Oh and I suppose you can average the first and second changes if you want to but i'm not sure what that tells you as the average probably isn't optimal in any sense. $\endgroup$
    – adunaic
    Sep 2, 2017 at 18:33
  • $\begingroup$ I realised that with cpt.meanvar I can find the changing point but it is not so sensitive on detecting when the "changing phase" stops. In other terms, this function give me the point in which the mean variance change, but it doesn t give the point corresponding to the end of the "changing phase". Now i'm looking to some method that allows me to extract change rates, may be with some fitting and extraction of the parameters obtained from the fitting. What do you think? $\endgroup$ Sep 3, 2017 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.