| nsp_wrapper | R Documentation |
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.
nsp_wrapper(
x,
alpha = 0.1,
variant = c("poly", "selfnorm", "ar", "tvreg"),
change_in = c("mean", "slope"),
deg = NULL,
M = 1000,
covariates = NULL,
ord = 1,
seed = NULL,
...
)
x |
A numeric vector. |
alpha |
Global significance level: with probability at least
|
variant |
Which NSP procedure to run:
|
change_in |
|
deg |
Degree of the piecewise polynomial. Derived from
|
M |
Number of intervals drawn. Defaults to |
covariates |
A design matrix for |
ord |
AR order for |
seed |
Optional seed. NSP draws random intervals, so a run is
reproducible only with one. The seed is scoped to this call:
|
... |
Additional arguments passed to the underlying nsp function. |
A ggcpt object with a populated regions slot.
cp means here, and what it does notNSP 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 regions slot, read with
cpt_regions();
marks itself, so print() says the cp column is a
midpoint and autoplot() shades the bands by default;
adds a cp_source column reading
"region_midpoint" to the changepoints tibble.
fryzlewicz2024nspggchangepoint
cpt_regions(), geom_cpt_region(),
cpt_confint().
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(),
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()
set.seed(2026)
x <- c(rnorm(100), rnorm(100, 4))
fit <- nsp_wrapper(x, M = 100, seed = 1)
cpt_regions(fit)
ggplot2::autoplot(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.