run_gibbs | R Documentation |
Runs the Gibbs sampler algorithm using using initial values for the parameters
run_gibbs(
M,
N,
w,
d,
as = 2,
bs = 100,
al = 2,
bl = 1000,
a = 2,
b = 1000,
alpha0 = 1/100,
lambda = 2,
maxIter = 10000,
par.values,
data,
cluster,
sigma2
)
M |
A scalar representing the number of points available for each observation |
N |
A scalar representing the number of observations |
w |
A scalar representing the minimum number of points in each interval between two change points |
d |
A scalar representing the number of clusters. |
as |
The hyperparameter value for the shape parameter in the inverse-gamma prior for the variance component |
bs |
The hyperparameter value for the scale parameter in the inverse-gamma prior for the variance component |
al |
The hyperparameter value for the shape parameter in the gamma prior for lambda |
bl |
The hyperparameter value for the scale parameter in the gamma prior for lambda |
a |
The hyperparameter value for the shape parameter in the gamma prior for alpha0 |
b |
The hyperparameter value for the scale parameter in the gamma prior for alpha0 |
alpha0 |
A scalar defining the parameter for the Dirichlet process prior that controls the number of clusters (or its initial values) |
lambda |
A scalar defining the parameter for the Truncate Poisson distribution that controls the number of change points (or its initial values) |
maxIter |
A scalar for the number of iteration to run in the Gibbs sampler |
par.values |
A list with lists with parameters for each cluster. The first argument in each list is the number of change points, then the positions for the change points, where T_1 = 1, T_last = M + 1, and for each interval between change points you need to specify a value for the constant level. If running the Gibbs sampler for a dataset with unknown number of change points, we suggest setting the number of change points for each cluster to be zero. Check example in README file. |
data |
a matrix of size M x N with data sequences in the columns |
cluster |
a vector with cluster assignments for each data sequence |
sigma2 |
a vector with variance components for each data sequence |
A list with estimates for each iteration of the Gibbs sampler for each parameter
d = 2 # two clusters
N = 5 # 5 data sequences
M = 50 # 50 observations for each data sequence
maxIter = 10 # number of Gibbs sampler iterations
data(data)
# initial values for each paramter and each cluster
par.values <- list(K = c(0, 0), Tl = list(50, 50), alpha = list(5, 10))
#cluster assignment for each data sequence
cluster <- kmeans(t(data), 2)$cluster
# variance for each data sequence
sigma2 <- apply(data, 2, var)
res <- run_gibbs(M, N, w = 10, d, as = 2, bs = 100, al = 2, bl = 1000, a = 2,
b = 1000, alpha0 = 1/100, lambda = 2, maxIter = 10, par.values, data,
cluster, sigma2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.