| DeCAFS | R Documentation |
This function implements the DeCAFS algorithm to detect abrupt changes in mean of a univariate data stream in the presence of local fluctuations and auto-correlated noise. It detects the changes under a penalised likelihood model where the data, y_1, ..., y_n, is
y_t = μ_t + ε_t
with ε_t an AR(1) process, and for t = 2, ..., N
μ_t = μ_{t-1} + η_t + δ_t
where at time t if we do not have a change then δ_t = 0 and η_t \sim N(0, σ_η^2); whereas if we have a change then δ_t \neq 0 and η_t=0.
DeCAFS estimates the change by minimising a cost equal to twice the negative log-likelihood of this model, with a penalty β for adding a change.
Note that the default DeCAFS behavior will assume the RWAR model, but fit on edge cases is still possible. For instance, should the user wish for DeCAFS to fit an AR model only with a piecewise constant signal, or similarly a model that just assumes random fluctuations in the signal, this can be specified within the initial parameter estimation, by setting the argument: modelParam = estimateParameters(y, model = "AR"). Similarly, to allow for negative autocorrelation estimation, set modelParam = estimateParameters(Y$y, phiLower = -1).
DeCAFS( data, beta = 2 * log(length(data)), modelParam = estimateParameters(data, warningMessage = warningMessage), penalties = NULL, warningMessage = TRUE )
data |
A vector of observations y |
beta |
The l0 penalty. The default one is |
modelParam |
A list of 3 initial model parameters: |
penalties |
Can be used as an alternative to the model parameters, a list of 3 initial penalties: |
warningMessage |
When |
Returns an s3 object of class DeCAFSout where:
$changepointsis the vector of change-point locations,
$signalis the estimated signal without the auto-correlated noise,
$costFunctionis the optimal cost in form of piecewise quadratics at the end of the sequence,
$estimatedParametersis a list of parameters estimates (if estimated, otherwise simply the initial modelParam input),
$datais the sequence of observations.
Romano, G., Rigaill, G., Runge, V., Fearnhead, P. (2021). Detecting Abrupt Changes in the Presence of Local Fluctuations and Autocorrelated Noise. Journal of the American Statistical Association. doi: 10.1080/01621459.2021.1909598.
library(ggplot2) set.seed(42) Y <- dataRWAR(n = 1e3, phi = .5, sdEta = 1, sdNu = 3, jumpSize = 15, type = "updown", nbSeg = 5) y <- Y$y res = DeCAFS(y) ggplot(data.frame(t = 1:length(y), y), aes(x = t, y = y)) + geom_point() + geom_vline(xintercept = res$changepoints, color = "red") + geom_vline(xintercept = Y$changepoints, col = "blue", lty = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.