Learn R Programming

BayesChange (version 2.1.3)

detect_cp_multi: Detect Change Points on multivariate time series

Description

Detect Change Points on multivariate time series

Usage

detect_cp_multi(
  data,
  n_iterations,
  q,
  k_0,
  nu_0,
  S_0,
  m_0,
  prior_delta_c = 1,
  prior_delta_d = 1,
  prior_var_phi = 0.1,
  print_progress = TRUE,
  user_seed = 1234L
)

Value

Function detect_cp_multi returns a list containing the following components:

  • $orders a matrix where each row corresponds to the output order of the corresponding iteration.

  • time computational time in seconds.

  • $phi_MCMC traceplot for \(\gamma\).

  • $phi_MCMC_01 a \(0/1\) vector, the \(n\)-th element is equal to \(1\) if the proposed \(\phi\) was accepted, \(0\) otherwise.

  • $sigma_MCMC traceplot for \(\sigma\).

  • $sigma_MCMC_01 a \(0/1\) vector, the \(n\)-th element is equal to \(1\) if the proposed \(\sigma\) was accepted, \(0\) otherwise.

  • $delta_MCMC traceplot for \(\delta\).

Arguments

data

a matrix where each row is a component of the time series and the columns correpospond to the times.

n_iterations

number of MCMC iterations.

q

probability of performing a split at each iteration.

k_0, nu_0, S_0, m_0

parameters for the Normal-Inverse-Wishart prior for \((\mu,\lambda)\).

prior_delta_c, prior_delta_d

parameters for the shifted Gamma prior for \(\delta\).

prior_var_phi

parameters for the correlation coefficient in the likelihood.

print_progress

If TRUE (default) print the progress bar.

user_seed

seed for random distribution generation.

Examples

Run this code

data_mat <- matrix(NA, nrow = 3, ncol = 100)

data_mat[1,] <- as.numeric(c(rnorm(50,0,0.100), rnorm(50,1,0.250)))
data_mat[2,] <- as.numeric(c(rnorm(50,0,0.125), rnorm(50,1,0.225)))
data_mat[3,] <- as.numeric(c(rnorm(50,0,0.175), rnorm(50,1,0.280)))

out <- detect_cp_multi(data = data_mat,
                              n_iterations = 2500,
                              q = 0.25,k_0 = 0.25, nu_0 = 4, S_0 = diag(1,3,3), m_0 = rep(0,3),
                              prior_delta_c = 2, prior_delta_d = 0.2, prior_var_phi = 0.1)


Run the code above in your browser using DataLab