IMPORTANT: Older versions of DeCAFS have a major bugthat severely affect the computational complexity of the procedure. Thiswas fixed from version 3.3.2. Should you have an older version installed(lower than 3.3.2) please make sure you update your DeCAFS packageeither through CRAN or GitHub. You can check your version number at thebottom of the documentation page of DeCAFS, viahelp("DeCAFS").
WHAT’S NEW: In addition to the automatic modelselection, we introduced a graphical iterative model selection procedurethat aids the user in selecting an appropriate model for a givensequence of observations. This tuning procedure can seriously improveperformances under more challenging scenarios. More details can be foundby checking the documentation:help("guidedModelSelection").
| DeCAFS vignette |
DeCAFS is ac++ implementation forR of the DeCAFS algorithm for performing optimal multiplechangepoint detection on detecting the change in mean in presence ofautocorrelation or random fluctuations in the data sequence.
To install the package from Github:
# devtools::install_github("gtromano/DeCAFS")library(DeCAFS)Alternatively one could fork this repository, and:
# install.packages("DeCAFS", repos = NULL, type = "source")library(DeCAFS)The packages requiresRcpp with compiler support for thestd library with theg++14 standard.
If any bug should be spotted, or for any information regarding thispackage, please email the package mantainer:g dotromano atlancaster.ac.uk.
We model a combination of a radom walk process (also known asstandard Brownian motion or Wiener Process) and an AR process. Letbe a random vectorm then for
,
where
Then, DeCAFS solves the following minimization problem:
Where our,
and
is an indicator function..
This demo shows some of the features present in theDeCAFS package.
Three functions at the moment are present in the package:
| functions | description |
|---|---|
| DeCAFS | Main function to run the DeCAFS algorithmon a sequence of observations |
| dataRWAR | Generate a realization of a RW+ARprocess |
| estimateParameters | Estimate the parameters of our model |
At the moment only two functions for data generation and parameterestimation are present, and they all are tailored for the Random Walk.Since l2-FPOP can tackle also other Stochastic Processes, more functionsare expected to be added.
We will start generating a Random Walk. The functiondataRWAR takes in:
set.seed(42)Y=dataRWAR(n =1e3,poisParam = .01,meanGap =15,phi = .5,sdEta =3,sdNu =1)y= Y[["y"]]Running DeCAFS is fairly straightforward:
res=DeCAFS(y)We can plot the DeCAFS segmentation (red lines), alongside with ourreal segmentation (dotted blue lines).

Alternatively, we can also pass all the required parameters in orderfor it to run. In this case, since we both have an AR and RW component,we will need to pass down both,
and
.
res=DeCAFS(y,beta =2*log(length(y)),modelParam =list(sdEta =3,sdNu =1, \phi = .7))## Error: <text>:1:84: unexpected input## 1: res = DeCAFS(y, beta = 2 * log(length(y)), modelParam = list(sdEta = 3, sdNu = 1, \## ^Let’s say we now have the.In this case our model simply becomes a random walk plus noise:
Our Algorithm is capable of dealing with this extreme situation:
set.seed(44)Y=dataRWAR(n =1e3,poisParam = .01,meanGap =15,phi =0,sdEta =2,sdNu =1)y= Y[["y"]]res=DeCAFS(y,beta =2*log(length(y)),modelParam =list(sdEta =2,sdNu =1,phi =0))which leads to the result:

Secondly, let’s say that theIn this case we end up with an Autoregressive model with changes.
In this case we need to set,and for
:
set.seed(46)Y=dataRWAR(n =1e3,poisParam = .01,meanGap =10,phi = .98,sdEta =0,sdNu =2)y= Y[["y"]]res=DeCAFS(y,beta =2*log(length(y)),modelParam =list(sdEta =0,sdNu =2,phi = .98))which leads to the result:

we see that in this case we miss one changepoint.
If you have interest to contribute to this package, please do notesitate to contact the maintainer:g dotromano atlancaster.ac.uk.