Skip to contents

Wraps DeCAFS::DeCAFS() (Romano, Rigaill, Runge and Fearnhead, 2022), which detects abrupt mean changes when the underlying signal also drifts (random-walk fluctuations) and the noise is AR(1)-autocorrelated — the two regimes in which plain change-in-mean methods over-detect. Model parameters are estimated automatically unless supplied.

Usage

decafs_wrapper(x, penalty = NULL, model_param = NULL, ...)

Arguments

x

A numeric vector.

penalty

Penalty \(\beta\) for adding a changepoint. Defaults to 2 * log(length(x)).

model_param

Optional list of model parameters (sdEta, sdNu, phi) as accepted by DeCAFS::DeCAFS(); when NULL they are estimated from the data.

...

Additional arguments passed to DeCAFS::DeCAFS().

Value

A ggcpt object. The data tibble carries the estimated signal in its fitted column.

References

Romano G, Rigaill G, Runge V, Fearnhead P (2022). “Detecting abrupt changes in the presence of local fluctuations and autocorrelated noise.” Journal of the American Statistical Association, 117(540), 2147–2162.

Examples

set.seed(2026)
res <- decafs_wrapper(c(rnorm(100), rnorm(100, 5)))
res$changepoints
#> # A tibble: 1 × 2
#>      cp cp_value
#>   <int>    <dbl>
#> 1   100    0.369