Wraps the nsp package (Fryzlewicz 2024). NSP inverts the usual
framing of post-selection inference: rather than estimating changepoint
locations and then asking whether they are real, it returns a set of
intervals, each of which contains at least one changepoint, with
the guarantee holding globally across all intervals simultaneously
at level alpha. The guarantee is exact and finite-sample, and the
self-normalised and autoregressive variants keep it under heavy tails,
heteroscedasticity and serial dependence.
Arguments
- x
A numeric vector.
- alpha
Global significance level: with probability at least \(1 - \alpha\), every returned interval contains a changepoint. Defaults to
0.1.- variant
Which NSP procedure to run:
"poly"(default)
nsp::nsp_poly(): piecewise polynomial signal, Gaussian noise of constant variance."selfnorm"nsp::nsp_poly_selfnorm(): self-normalised, for heavy tails and heteroscedasticity. Slower."ar"nsp::nsp_poly_ar(): autoregressive noise of orderord."tvreg"nsp::nsp_tvreg(): a general linear model whose coefficients change; requirescovariates.
- change_in
"mean"(a piecewise-constant signal,deg = 0) or"slope"(piecewise linear,deg = 1). Ignored whendegis given explicitly, and whenvariant = "tvreg"(which takes its model fromcovariates).- deg
Degree of the piecewise polynomial. Derived from
change_inwhenNULL.- M
Number of intervals drawn. Defaults to
1000; the engine's own default.- covariates
A design matrix for
variant = "tvreg", with one row per observation.- ord
AR order for
variant = "ar". Defaults to1.- seed
Optional seed. NSP draws random intervals, so a run is reproducible only with one. The seed is scoped to this call:
.Random.seedis saved and restored, so a seeded call inside a simulation loop does not pin the loop's own stream.- ...
Additional arguments passed to the underlying nsp function.
What cp means here, and what it does not
NSP produces no point estimates. This wrapper still fills the cp
column (with the midpoint of each interval) because every
downstream consumer in the package (augment(),
cpt_metrics(), cpt_consensus(),
autoplot()) is built on that column, and a result with an empty
cp would silently score as "found nothing". The midpoint is
not an estimate of the changepoint location and must not be
reported as one: the interval is the inferential object. The result
therefore
carries the intervals in a
regionsslot, read withcpt_regions();marks itself, so
print()says thecpcolumn is a midpoint andautoplot()shades the bands by default;adds a
cp_sourcecolumn reading"region_midpoint"to the changepoints tibble.
References
Fryzlewicz P (2024). “Narrowest significance pursuit: inference for multiple change-points in linear models.” Journal of the American Statistical Association, 119(546), 1633–1646. doi:10.1080/01621459.2023.2211733 .
See also
cpt_regions(), geom_cpt_region(),
cpt_confint().
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(),
ocd_wrapper(),
pilliat_wrapper(),
segmented_wrapper(),
smuce_wrapper(),
sn_wrapper(),
strucchange_wrapper(),
taylor_wrapper(),
tguh_wrapper(),
trend_wrapper(),
var_wrapper(),
wbs2_wrapper(),
wbs_wrapper(),
wbsts_wrapper()

