bcp: Fit the changepoint detection method to multiple variables

Description Usage Arguments Value

Description

Apply Bayesian Minimum Description Length to detect multiple changepoints, individually for a group of time series data (one for each variable to be monitored). Returns the optimal changepoint models, and graphic outputs as a pdf file.

Usage

1
2
3
4
5
bcp(X, pdf_file = "bcp.pdf", select = "MAP", iter = 10000, thin = max(1,
  iter/1000), p = 2, time_unit = "month", seasonal_means = "harmonic",
  k = 3, scale_trend_design = 0.05, fit = "marlik", penalty = "bmdl",
  nu = 5, a = 1, b = 1, width = 8, height = 4, mar = c(5, 5, 4, 1),
  mfrow = c(1, 1), start_eta = NULL, track_time = TRUE)

Arguments

X

Variables to be monitored, a data.frame of numerics, with each row being a variable, in the format of a time series of length n. If such information is in a CSV file, X can also be the name of this file, with extension name, and a path if needed.

pdf_file

Name of the output pdf file with extension name, a character; can include path.

select

The selected model to plot, 'MAP' for maximum a posterior, or 'BMA' for median probability model under Bayesian model averaging.

iter

Total number of MCMC iterations.

thin

Thinning; save one MCMC iteration for every thin number of iterations.

p

The order of the AR process.

time_unit

Default is 'month' ('week' may be added in the future).

seasonal_means

The seasonal means variables in the linear model. Either 'fixed_effects' such that each season has a coefficient (with no intercept), or 'harmonic' for harmonic regression (with an intercept).

k

The highest degree of harmonic regression. It is only used if the argument seasonal_means == 'harmonic'.

scale_trend_design

The factor multiplied to the design matrix of trend. Default is 1/50.

fit

For likelihood calculation, 'marlik' for marginal likelihood, or 'lik' for likelihood. Note that the 'lik' option already includes the two-part MDL of mu.

penalty

For penalty function calculation, 'bmdl' for Beta-Binomial prior, or 'mdl' for MDL.

nu

Prior variance scale of mu; only used if fit == 'marlik'.

a

The first and second parameters in the Beta-Binomial prior; only used if penalty == 'bmdl'.

b

The first and second parameters in the Beta-Binomial prior; only used if penalty == 'bmdl'.

width, height

Width and height of the output pdf (per page).

mar

Margin of the output pdf (per page).

mfrow

Number of rows and columns of figures on per pdf page.

start_eta

A vector of 0/1 indicators for the initial model, or NULL to randomly sample an initial model.

track_time

Logical, whether to show runtime on screen.

Value

eta_all

Estimated changepoints for all variables; a matrix of 0/1 indicators, where each row is for one variable, in the same order as the input data X.

seasonal_cycles_all

Estimated seasonal means for all variables, where each row is for one variable.

mean_and_trend_all

Estimated linear trends for all variables, where each row is for one variable.


yingboli/BayesMDL documentation built on May 29, 2019, 12:18 p.m.