
Classical single-changepoint tests (Pettitt, Buishand, SNHT)
Source:R/wrap-applied.R
trend_wrapper.RdWraps 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, ...)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
Pettitt AN (1979). “A non-parametric approach to the change-point problem.” Journal of the Royal Statistical Society: Series C, 28(2), 126–135. doi:10.2307/2346729 .
Buishand TA (1982). “Some methods for testing the homogeneity of rainfall records.” Journal of Hydrology, 58(1–2), 11–27. doi:10.1016/0022-1694(82)90066-X .
Alexandersson H (1986). “A homogeneity test applied to precipitation data.” Journal of Climatology, 6(6), 661–675. doi:10.1002/joc.3370060607 .
See also
Other changepoint engines:
bcp_wrapper(),
beast_wrapper(),
bfast_wrapper(),
binsegrcpp_wrapper(),
bocpd_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")
#> ggcpt (changepoint detection result)
#> Method: pettitt
#> Change in: mean
#> Changepoints found: 1
#> CP convention: left
#> Penalty: alpha = 0.05
#> Series length: 120
#>
#> Changepoints:
#> # A tibble: 1 × 4
#> cp cp_value p_value statistic
#> <int> <dbl> <dbl> <dbl>
#> 1 60 -0.999 1.54e-14 3072
trend_wrapper(x, test = "snht")
#> ggcpt (changepoint detection result)
#> Method: snht
#> Change in: mean
#> Changepoints found: 1
#> CP convention: left
#> Penalty: alpha = 0.05
#> Series length: 120
#>
#> Changepoints:
#> # A tibble: 1 × 4
#> cp cp_value p_value statistic
#> <int> <dbl> <dbl> <dbl>
#> 1 60 -0.999 0 59.1