cpt_test_null: Test for a change anywhere in a series

View source: R/null.R

cpt_test_nullR Documentation

Test for a change anywhere in a series

Description

A test of the global null hypothesis "the series has no changepoint", the question an empty detection raises. Nothing is located first, so nothing is selected, and the p-value means what it says.

Usage

cpt_test_null(x, method = c("cusum", "pettitt", "supF"), index = NULL)

Arguments

x

A numeric series, or a ggcpt fit (its series is used).

method

Which test:

"cusum"

(the default) the CUSUM test for a change in mean: the largest standardised cumulative-sum deviation, referred to the Kolmogorov distribution of the supremum of a Brownian bridge. The noise scale is estimated from first differences, which a change barely affects.

"pettitt"

Pettitt's rank test, distribution-free, for a shift in location (approximate p-value).

"supF"

Andrews' sup-F structural change test for a change in mean, with 15% trimming, through strucchange.

index

Optional time index for a bare series.

Value

A tibble with one row: method, statistic, p_value, location (where the statistic peaks: the most likely changepoint, reported for orientation only), n and selection_adjusted (TRUE).

Assumptions

All three assume independent observations. Under positive autocorrelation they reject too often, which is the same failure the detectors share; see cpt_assumptions().

See Also

cpt_null_power() for what an empty answer could have detected, cpt_test_at() for a pre-specified date.

Other inference: cpt_abruptness(), cpt_assumptions(), cpt_attribute(), cpt_attribute_event(), cpt_confint_coverage(), cpt_effect(), cpt_gof(), cpt_k_weights(), cpt_null_power(), cpt_robustness(), cpt_screen(), cpt_test_at()

Examples


set.seed(1)
cpt_test_null(rnorm(200))
shifted <- c(rnorm(100), rnorm(100, 0.6))
cpt_test_null(shifted, method = "pettitt")
cpt_test_null(shifted, method = "supF")


ggchangepoint documentation built on Nov. 5, 2026, 9:06 a.m.