BayesCPclust aims to estimate the change points in constant-wise data sequences while simultaneously performing clustering. A Gibbs sampler algorithm was developed to estimate the number of clusters, cluster assignments, number of change points, their positions, and constant levels.
For more details see paper in arXiv paper link
You can install the development version of BayesCPclust from GitHub with:
# install.packages("devtools")
::install_github("acarolcruz/BayesCPclust") devtools
The following example illustrate the process of performing clustering and estimations for constant-wise change-point data using the data example ‘data’. When there is no prior knowledge of the number of change points and their locations, we suggest to initialize the algortihm with zero change points for all clusters and the position for the change points (Tl) should be defined as the number of observations (M).
= 2 # two clusters
d = 5 # 5 data sequences
N = 50 # 50 observations for each data sequence
M = 10 # number of Gibbs sampler iterations
maxIter
data(data)
# initial values for each paramter and each cluster
<- list(K = c(0, 0), Tl = list(50, 50), alpha = list(5, 10))
par.values
#cluster assignment for each data sequence
<- kmeans(t(data), 2)$cluster
cluster
# variance for each data sequence
<- apply(data, 2, var)
sigma2
<- run_gibbs(M, N, w = 10, d, as = 2, bs = 100, al = 2, bl = 1000, a = 2,
res b = 1000, alpha0 = 1/100, lambda = 2, maxIter = 10, par.values,
data, cluster, sigma2)
$clusters[maxIter,]
res# 3 7 7 7 7