[R] problem (un)detecting changepoints

Martyn Byng Martyn.Byng at nag.co.uk
Mon Jan 27 17:35:43 CET 2014


Hi,

I don't think you are doing anything wrong, the routine is doing what it
is documented to do, from ?cpt.mean

    cpt: Vector containing the changepoint locations for the penalty
supplied.  This always ends with n.

i.e. as your series is of length 50, the last value returned in cpts
will always be 50.

Martyn

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Enrico R. Crema
Sent: 27 January 2014 13:01
To: R help
Subject: [R] problem (un)detecting changepoints

Dear List,

I am using the cpt.mean() function in the "changepoint" package to
detect change-points in my data and noticed that when there are no
visible changes, the function returns the last point as the point of
change. The following script can illustrate this:

table(unlist(replicate(500,cpt.mean(rnorm(50),method="PELT")@cpts)))

the result will return a uniform distribution from 1 to 49 (with ca 20
cpts located for each), and then 500 cases where the cpts is located on
the last vector. Clearly, cpt.mean returns the index of the last vector
value (here 50) for change in the time-series. I wonder if I am doing
something wrong here, but I think the function should return a NA... 

Many thanks in advance,
Enrico 

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

________________________________________________________________________
This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}




More information about the R-help mailing list