
Find where a time series changed with any of 51 methods, and get the same tidy, plottable answer from every one.
library(ggchangepoint)
fit <- cpt_detect(Nile, method = "smuce")
fit$changepoints
#> # A tibble: 1 ร 5
#> cp cp_index cp_value ci_lower ci_upper
#> <int> <dbl> <dbl> <int> <int>
#> 1 28 1898 1100 26 31
autoplot(fit, show_ci = TRUE)

Five detectors built on different ideas agree:
ggcpt_compare_table(Nile, methods = c("smuce", "not", "wbs", "mosum",
"strucchange"))
#> # A tibble: 5 ร 3
#> method cp cp_value
#> <chr> <int> <dbl>
#> 1 smuce 28 1100
#> 2 not 28 1100
#> 3 wbs 28 1100
#> 4 mosum 28 1100
#> 5 strucchange 28 1100
| You want to know | Call |
|:---|:---|
| How big was the change? | cpt_effect(fit) |
| Where exactly, with no model assumed? | cpt_confint(fit, method = "conformal") |
| What would have happened without it? | cpt_counterfactual(fit) |
| Which of my sensors changed? | cpt_attribute(fit) |
| Did anything change in a year I already had in mind? | cpt_test_at(Nile, when = 1899) |
| Should I believe this count? | cpt_assumptions(fit) |
| Which method suits my data? | cpt_recommend(noise = "autocorrelated") |
| A stretch that returns to normal? | cpt_detect(x, method = "capa") |
| Watching a live stream? | cpt_monitor("cusum", baseline = b) |
| What can each of the 51 methods do? | cpt_methods() |
install.packages("ggchangepoint")ggchangepoint::cpt_install_engines(c("core", "regression")) adds
the engines this page uses ("all" for every one; three ship with
the package).cpt_detect(your_series), then autoplot() the result.| For | Do |
|:---|:---|
| Data far from unit scale | Use change_in = "meanvar", or standardise first: pelt, binseg and fpop assume unit noise |
| Autocorrelated series | Check with cpt_assumptions(fit); cpt_robustness(fit) re-runs under another noise model |
| A date fixed in advance | cpt_test_at() gives an exact test at that date |
| Gaps in the series | na_action = "omit" keeps the original positions |
Reference ยท Choosing a method ยท Beyond the location ยท Best practice ยท Introduction
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.