tsEvaChangepts {RtsEva} | R Documentation |
This function applies the PELT method for change point detection in a time series. It returns the mean and variance of the series segments between change points.
tsEvaChangepts(series, timeWindow, timeStamps)
series |
A numeric vector representing the time series. |
timeWindow |
An integer specifying the minimum length of segments. |
timeStamps |
A vector of timestamps corresponding to the series data points. |
A list containing:
trend
A numeric vector of the same length as series, with each segment between change points filled with its mean value
variance
A numeric vector of the same length as series, with each segment between change points filled with its variance
changepoints
A vector of timestamps at which change points were detected
timeAndSeries <- ArdecheStMartin
timeStamps <- ArdecheStMartin[,1]
series <- ArdecheStMartin[,2]
timeWindow <- 30*365 # 30 years
result <- tsEvaChangepts(series, timeWindow, timeStamps)
plot(timeAndSeries, type = "l")
lines(timeStamps,result$trend,col=2)
points(timeStamps[result$changepoints], result$trend[result$changepoints], col = "red")