ex = mcp_example("demo", with_fit = TRUE) is the new interface that replaces the
ex_* datasets in prior versions. This reduces clutter of the namespace/documentation and the size of the package. It also gives the user richer details on the simulation and analyses. For “demo”, the
ex_demo dataset is now
ex$data and the
Get fits and predictions for in-sample and out-of-sample data. Read more in the article on these functions.
predict(fit)to get predicted values and quantiles.
fitted(fit)to get estimated values and quantiles.
residuals(fit)to get residuals and quantiles.
All of the above functions include many arguments that align with (and extends) the options already in
plot.mcpfit(), including getting fits/predictions for sigma (
which_y = "sigma"), for the prior (
prior = TRUE), and arbitrary quantiles (
probs = c(0.1, 0.5, 0.999)). Use the
newdata argument to get out-of-sample fitted/predicted values. Set
summary = FALSE to get per-draw values.
Added support for weighted regression for gaussian families:
model = list(y | weights(weight_column) ~ 1 + x). Weights are visualized as dot sizes in
Support for more link functions across families (e.g.,
family = gaussian(link = "log")):
gaussian: “identity”, “log”
binomial: “logit”, “probit”, “identity”
bernoulli: “logit”, “probit”, “identity”
poisson: “log”, “identity”
scale = "response" (default), they return fits on the observed scale. When
scale = "linear", they return fits on the parameter scale where the linear trends are. Useful for model understanding and debugging.
plot(fit, facet_by = "varying_column"). Previous releases only displayed population-level change points.
rate = FALSEfor binomial models.
plot(fit)are not located directly on the x-axis. They were “floating” 5% above the x-axis in the previous releases.
nsamples reduces the number of samples used in most functions to speed up processing.
nsamples = NULL uses all samples for maximum accuracy.
arma in many functions toggles whether autoregressive effects should be modelled.
Although the API is still in alpha, feel free to try extracting samples using
mcp:::tidy_samples(fit). This is useful for further processing using
bayesplot, etc. and is used extensively internally in
mcp. One useful feature is computing absolute values for varying change points:
mcp:::tidy_samples(fit, population = FALSE, absolute = TRUE). Feedback is appreciated before
tidy_samples will to become part of the
mcp API in a future release.
plot(fit)are now scaled to 20% of the plot for each chain X changepoint combo. This addresses a common problem where a wide posterior was almost invisibly low when a narrow posterior was present. This means that heights should only be compared within each chain x changepoint combo - not across.
mcprobust and agile to develop.
mcpnow use defensive programming with helpful error messages. The Test suite includes 3600+ tests.
predict(), etc. are now considerably faster for AR(N) due to vectorization of the underlying code.
The API and internal structure should be stable now. v0.2.0 will be released on CRAN.
family = gaussian()using
~ sigma([formula here]).
~ ar(order, formula), typically like
y ~ 1 + x + ar(2)for AR(2). Simulate AR(N) models from scratch or given known data with
fit$simulate(). The article on AR(N) has more details and examples. AR(N) models are popular to detect changes in time-series.
plot(fit, cp_dens = FALSE).
plot(fit, q_fit = TRUE).
plot(fit, q_fit = c(0.025, 0.5, 0.975))plots 95% HDI and the median.
plot(fit, q_predict = TRUE).
plot(fit, geom_data = "line")). The latter is useful for time series. Disable using
geom_data = FALSE.
options(mc.cores = 3)for considerable speed gains for the rest of the session. All vignettes/articles have been updated to recommend this as a default, though serial sampling is still the technical default.
mcp(..., cores = 3)does the same thing on a call-by-ball basis.
fit$simulate()adds the simulation parameters as an attribute (
attr(y, "simulate")) to the predicted variable.
summary()recognizes this and adds the simulated values to the results table (columns
match) so that one can inspect whether the values were recovered.
plot(fit, which_y = "sigma")to plot the residual standard deviation on the y-axis. It works for AR(N) as well, e.g.,
which_y = "ar1",
which_y = "ar2", etc. This is useful to visualize change points in variance and autocorrelation. The vignettes on variance and autocorrelations have been updated with worked examples.
prior = list(cp_1 = "dirichlet(1)", cp_2 = ...). Read pros and cons here.
mcp(..., sample = "prior")or
mcp(..., sample = "both")and most methods can now take the prior:
plot(fit, prior = TRUE),
plot_pars(fit, prior = TRUE),
summary(fit, prior = TRUE),
ranef(fit, prior = TRUE).
mcpcan now be cited! Call
citation("mcp")or see the pre-print here: https://osf.io/fzqxv.
plot()only visualize the total fit while
plot_pars()only visualize individual parameters. These functions were mixed in
updatehas been discarded from
mcp()(it’s all on
initshas been added.
mcpmore future proof. The biggest internal change is that
dclonepackage. Among other things, this gives faster and cleaner installations.
First public release.