bcpmeta.model: Identify the Optimal Changepoint Configuration

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/bcpmeta.model.R

Description

Implement a MCMC algorithm to quick search for the optimal changepoint configuration that has the largest posterior probability.

Usage

1
2
3
4
5
bcpmeta.model(X, meta, iter = 10000, thin = 10, trend = TRUE, 
              EB = TRUE, mu0 = NULL, nu0 = 5, a1 = 1, a2 = 1, 
              b1 = 19, b2 = 3, phi.lower = -0.99, phi.upper = 0.99, 
              start.eta = NULL, track.time = TRUE, show.summary = TRUE, 
              start.year = 1, meta.year = FALSE)

Arguments

X

a numerical vector. Observed time series.

meta

metadata. Either a vector of 0-1 indicators of the same length as X, or a numerical vector of the time indice of the metadata times.

iter

total number of iterations of MCMC.

thin

thinning; save one iteration in every thin number of iterations.

trend

logical indicating whether to allow the linear trend component.

EB

logical indicating whether to use the empirical Bayes method for sigma^2 and phi.

mu0

prior mean of regime-wise means mu_j. If NULL, set to the default value mean(X).

nu0

constant factor in prior variance of regim-wise means mu_j.

a1

the first parameter in the Beta-Binomial prior of non-metadata times.

a2

the first parameter in the Beta-Binomial prior of metadata times.

b1

the second parameter in the Beta-Binomial prior of non-metadata times.

b2

the second parameter in the Beta-Binomial prior of metadata times.

phi.lower

lower bound of the range of phi

phi.upper

upper bound of the range of phi

start.eta

initial value of the changepoint configuration eta for the MCMC. If NULL, generated randomly.

track.time

logical indicating whether to show process time.

show.summary

logical indicating whether to show the top 5 configurations.

start.year

year index of the first time point in the series.

meta.year

logical indicating whether meta is indexed in year, if it consists of the locations of the metadata times (instead of 0-1 indicators).

Details

A Metropolis-Hastings algorithm with interwine of two transitions, a component-wise updating and a simple random swapping. See references for details.

Value

Eta

a (iter/thin+1) * length(X) matrix. Each row is a changepoint configuration visited by MCMC, in the format of a vector 0-1 indicators.

map200

a 200 * (length(X) + 3) matrix. The best 200 changepoint configurations, listed in desecending order. Each row is a vector of 0-1 indicators, followed by lml (log likelihood up to a constant), phi.eb (if EB == TRUE, the empirical Bayes estimate of phi under that configuration) and lpost (log posterior up to a constant).

X

observed time series, same as the input value.

meta

metadata, same as the input value.

input.parameters

input parameters. Use command names to check its components.

Author(s)

Yingbo Li

Maintainer: Yingbo Li <ybli@clemson.edu>

References

Li, Y. and Lund, R. (2014) Bayesian Mulitple Changepoint Detection Using Metadata. (submitted)

See Also

Function marginal.plot uses the output of this function as input.

Examples

1
2
3
4
5
6
7
## Create a time series of length 200 with three mean shifts at 50, 100, 150.
data = simgen(2, 1);
X = data$X[1, ];  ## time series
meta = data$meta;  ## locations of metadata times

## For illustration purpose, number of MCMC iteration is set to a small value.
results = bcpmeta.model(X, meta = meta, iter = 1e3, trend = FALSE); 

bcpmeta documentation built on May 1, 2019, 6:48 p.m.