Learn R Programming

RegimeChange (version 0.1.1)

fpop_detect: FPOP - Functional Pruning Optimal Partitioning

Description

More efficient than PELT for certain data types by maintaining piecewise quadratic cost functions instead of just minimum values. Achieves O(n) complexity in practice.

Usage

fpop_detect(data, penalty = "bic", min_segment = 2, cost_type = "mean")

Value

List with:

changepoints

Vector of changepoint locations

cost

Final optimal cost

n_candidates

Average candidates per time point (efficiency metric)

Arguments

data

Numeric vector of observations

penalty

Penalty for adding a changepoint. Can be:

  • "bic": log(n)

  • "aic": 2

  • "mbic": 3*log(n)

  • numeric: Custom penalty value

min_segment

Minimum segment length (default: 2)

cost_type

Type of cost function:

  • "mean": Gaussian mean change (default)

  • "meanvar": Gaussian mean and variance change

  • "poisson": Poisson rate change

References

Maidstone, R., Hocking, T., Rigaill, G., and Fearnhead, P. (2017). On optimal multiple changepoint algorithms for large data. Statistics and Computing, 27(2), 519-533.

Examples

Run this code
data <- c(rnorm(100, 0), rnorm(100, 3), rnorm(100, 1))
result <- fpop_detect(data, penalty = "bic")
print(result$changepoints)

Run the code above in your browser using DataLab