Skip to contents

Wraps wbsts::wbs.lsw() (Korkas and Fryzlewicz): wild binary segmentation applied to the locally stationary wavelet spectrum, so it detects changes in the second-order structure (variance and autocovariance) of a nonstationary series. Where wbs looks for jumps in the level, this looks for jumps in how the series behaves.

Usage

wbsts_wrapper(
  x,
  n_intervals = 0,
  cstar = 0.75,
  lambda = 0.75,
  scales = NULL,
  seed = NULL,
  ...
)

Arguments

x

A numeric vector.

n_intervals

Number of random intervals (M). Defaults to 0, which is the engine's "all dyadic intervals" setting.

cstar

The unbalancedness parameter \(c_\star\) of the search: a candidate split may leave at most this fraction of its interval on either side. Between 0.5 and 1; defaults to the engine's 0.75.

lambda

How many wavelet scales are used when scales is NULL: floor(3 * lambda * log(log(n))) of them, from the finest down. Defaults to the engine's 0.75.

scales

Wavelet scales to use: at least two different whole numbers from 1 to floor(log2(n)) - 1. NULL lets the engine choose.

seed

Optional seed. The seed is scoped to this call: .Random.seed is saved and restored, so a seeded call inside a simulation loop does not pin the loop's own stream.

...

Additional arguments passed to wbsts::wbs.lsw().

Value

A ggcpt object with change_in = "var".

References

Korkas KK, Fryzlewicz P (2017). “Multiple change-point detection for non-stationary time series using wild binary segmentation.” Statistica Sinica, 27(1), 287–311. doi:10.5705/ss.202015.0262 .

Examples

# \donttest{
set.seed(2026)
y <- c(as.numeric(stats::arima.sim(list(ar = 0.1), 250)),
       as.numeric(stats::arima.sim(list(ar = 0.9), 250)))
wbsts_wrapper(y)
#> ggcpt (changepoint detection result)
#>   Method:             wbsts
#>   Change in:          var
#>   Changepoints found: 1
#>   CP convention:      left
#>   Penalty:            threshold
#>   Series length:      500
#> 
#> Changepoints:
#> # A tibble: 1 × 2
#>      cp cp_value
#>   <int>    <dbl>
#> 1   248    0.654
# }