trend_wrapper: Classical single-changepoint tests (Pettitt, Buishand, SNHT)

View source: R/wrap-applied.R

trend_wrapperR Documentation

Classical single-changepoint tests (Pettitt, Buishand, SNHT)

Description

Wraps the three single-change tests that hydrology and climatology use as their standard vocabulary, from the trend package. All three test H_0: no change against a single change in the mean, differing in how they measure it:

"pettitt"

a rank-based (Mann-Whitney) statistic, distribution-free and robust to outliers.

"buishand"

the Buishand range test, based on rescaled adjusted partial sums; assumes normality.

"snht"

the standard normal homogeneity test of Alexandersson, the reference method for detecting inhomogeneities in climate records.

Each reports a location and a p-value, and, unlike most engines here, that p-value is valid, because the location was not chosen from a larger model search.

Usage

trend_wrapper(x, test = c("pettitt", "buishand", "snht"), alpha = 0.05, ...)

Arguments

x

A numeric vector.

test

Which test to run. Defaults to "pettitt".

alpha

Significance level below which the changepoint is reported. Defaults to 0.05. A test that does not reject returns an empty result rather than an unsupported location.

...

Additional arguments passed to the trend function.

Value

A ggcpt object with the test's p_value and statistic on the changepoints tibble. The per-position test statistic is available through cpt_statistic().

References

\insertRef

pettitt1979testggchangepoint

\insertRef

buishand1982testsggchangepoint

\insertRef

alexandersson1986snhtggchangepoint

See Also

Other changepoint engines: bcp_wrapper(), beast_wrapper(), bfast_wrapper(), binsegrcpp_wrapper(), bocpd_wrapper(), capa_wrapper(), cpm_wrapper(), cpop_wrapper(), cpt_wrapper(), decafs_wrapper(), ecp_wrapper(), envcpt_wrapper(), esac_wrapper(), fabisearch_wrapper(), fastcpd_wrapper(), fcov_wrapper(), fmean_wrapper(), fpop_wrapper(), geomcp_wrapper(), hdcov_wrapper(), hdreg_wrapper(), idetect_wrapper(), inspect_wrapper(), kcp_wrapper(), kwc_wrapper(), mcp_wrapper(), mosum_wrapper(), network_wrapper(), not_wrapper(), npmojo_wrapper(), nsp_wrapper(), ocd_wrapper(), pilliat_wrapper(), segmented_wrapper(), smuce_wrapper(), sn_wrapper(), strucchange_wrapper(), taylor_wrapper(), tguh_wrapper(), var_wrapper(), wbs2_wrapper(), wbs_wrapper(), wbsts_wrapper()

Examples


set.seed(2026)
x <- c(rnorm(60), rnorm(60, 2))
trend_wrapper(x, test = "pettitt")
trend_wrapper(x, test = "snht")


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