This function wraps a number of cpt functions from the changepoint
package and the cpt.np() function from the changepoint.np package.
It is handy that users can use this function to get the same changepoint
results as these functions output individually. Moreover, it returns a tibble
that inherits the tidyverse style. Functions from the changepoint package do
require data normality assumption by default, yet changepoint.np is a
non-parametric way to detect changepoints and let data speak by itself.
If user sets change_in as np (or cpt_np), a seed should
be set before using the function for the sake of reproducibility. For more
details on the changepoint and changepoint.np packages, please refer to
their documentation.
Arguments
- data
A numeric vector.
- change_in
Choice of
mean_var,mean,var, andnp(orcpt_npfor backward compatibility). Each choice corresponds tocpt.meanvar(),cpt.mean(),cpt.var()andcpt.np()respectively. The default ismean_var.- cp_method
A wide range of choices (i.e.,
AMOC,PELT,SegNeighorBinSeg). Please note whenchange_inisnporcpt_np,PELTis the only option.- ...
Extra arguments for each
cptfunction mentioned in thechange_insection.
Value
A tibble including which point(s) is/are the changepoint along with
raw changepoint value corresponding to that changepoint. Changepoint
locations follow the convention of the changepoint package: the
last index of the left segment. The upstream cpt object is
attached as the "ggcpt_fit" attribute, which is what
cpt_detect() stores in the result's $fit.
Standardise the data for a change in mean
With change_in = "mean" the upstream Normal cost assumes a noise
standard deviation of 1 and the penalty is compared against the raw
residual sum of squares, so a series with wider noise is under-penalised
and over-segmented: 29 changepoints instead of 1 at \(\sigma = 3\) in a
measured example. Standardise the series first, or use
change_in = "mean_var", which estimates a variance per segment and
is unaffected. See the scale-sensitivity section of
cpt_detect.
References
Killick R, Eckley I (2014). “changepoint: An R package for changepoint analysis.” Journal of statistical software, 58(3), 1–19.
See also
Other changepoint engines:
bcp_wrapper(),
beast_wrapper(),
bfast_wrapper(),
binsegrcpp_wrapper(),
bocpd_wrapper(),
cpm_wrapper(),
cpop_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(),
trend_wrapper(),
var_wrapper(),
wbs2_wrapper(),
wbs_wrapper(),
wbsts_wrapper()
