Learn R Programming

BayesChange (version 2.1.3)

plot.DetectCpObj: Plot estimated change points

Description

The plot method plots the estimates change points estimated through the salso algorithm, for a DetectCpObj class object.

Usage

# S3 method for DetectCpObj
plot(
  x,
  y = NULL,
  plot_freq = FALSE,
  loss = "VI",
  maxNClusters = 0,
  nRuns = 16,
  maxZealousAttempts = 10,
  ...
)

Value

The function returns a ggplot object representing the detected change points. If plot_freq = TRUE is plotted also an histogram with the frequency of times that a change point has been detected in the MCMC chain.

Arguments

x

an object of class DetectCPObj.

y, ...

parameters of the generic method.

plot_freq

if TRUE also the histogram with the empirical frequency of each change point is plotted.

loss

The loss function used to estimate the final partition, it can be "VI", "binder", "omARI", "NVI", "ID", "NID".

maxNClusters

maximum number of clusters in salso procedure.

nRuns

number of runs in salso procedure.

maxZealousAttempts

maximum number of zealous attempts in salso procedure.

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(data = data_mat, n_iterations = 2500, n_burnin = 500,
                 params = list(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), kernel = "ts")
plot(out)



Run the code above in your browser using DataLab