| mcp_wrapper | R Documentation |
Wraps mcp::mcp() (Lindeløv): a Bayesian multiple-changepoint
regression specified as a list of formulas, one per segment. This
is the most expressive detector in the package: each segment can have its
own intercept, slope, variance and autocorrelation, and the changepoints
themselves get full posterior distributions rather than point estimates,
summarised here as ci_lower/ci_upper on the changepoints
tibble. (ggcpt_posterior() draws a per-location
probability profile, which only bcp and Rbeast expose; it
does not accept an mcp result.)
mcp_wrapper(
x,
change_in = c("mean", "slope", "var"),
n_changepoints = 1,
model = NULL,
prior = list(),
iter = 3000,
adapt = 1000,
chains = 3,
seed = NULL,
...
)
x |
A numeric vector. |
change_in |
Shorthand for the segment model when |
n_changepoints |
Number of changepoints in the shorthand model.
Defaults to |
model |
An explicit mcp model: a list of formulas. Overrides
|
prior |
Optional named list of priors, passed to |
iter, adapt, chains |
Sampler settings, passed through. |
seed |
Optional seed. The seed is scoped to this call:
|
... |
Additional arguments passed to |
A ggcpt object. The changepoints tibble carries the
posterior mean location together with ci_lower/ci_upper
from the posterior quantiles, each converted from mcp's
continuous cp_1, cp_2, ... to the last observation
before the change (ceiling(cp) - 1, because mcp starts a
segment at x >= cp), and $data$fitted holds the
posterior predictive mean, so autoplot(show_ci = TRUE,
show_fit = TRUE) shows both.
mcp samples through JAGS, a separate program installed outside R.
Having the package is not the same as being able to run it:
mcp imports rjags, and on some platforms rjags
installs happily and only fails when it looks for the JAGS library at run
time, in which case mcp::mcp() returns a fit carrying no
posterior samples, with a warning rather than an error. This wrapper
checks for that and says so plainly instead of failing several frames
later inside summary(). Everything else in the package works
without JAGS.
lindelov2020mcpggchangepoint
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(),
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()
# Not run by R CMD check: whether this works depends on a *system*
# library, and no test of installed R packages predicts that reliably --
# `rjags` can be present and still fail to find JAGS at run time.
## Not run:
set.seed(2026)
fit <- mcp_wrapper(c(rnorm(60), rnorm(60, 4)), iter = 500, adapt = 200)
fit
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.