postK: Marginal probability of K

View source: R/postK.R

postKR Documentation

Marginal probability of K

Description

Marginal probability of K

Usage

postK(kstar, w, M, Y, cluster, sigma2, lambda, clusteri)

Arguments

kstar

A scalar with the number maximum of change points in all clusters

w

A scalar representing the minimum number of points in each interval between two change points

M

A scalar representing the number of points available for each data sequence

Y

A matrix M x N with the data sequences

cluster

A vector containing the cluster assignments for the data sequences (or its initial values)

sigma2

A vector with the variances of the data sequences (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)

clusteri

A scalar with the index of a cluster

Value

A numerical value corresponding to the sampled number of change points, k, for a given cluster

Note

This function is called within the Gibbs sampler, but it can also de called separately.

See Also

[gibbs_alg()]

Examples

postK(kstar = 2, w = 10, M = 50, Y = data, cluster = c(1,1,2,1,2),
sigma2 = apply(data, 2, var), lambda = 2, clusteri = 1)


BayesCPclust documentation built on April 4, 2025, 5:19 a.m.