Skip to contents

Formula: P(z_i | z_{-i}, y) with theta marginalized

Usage

Crpcol(y, alpha = 1, n_iter = 50, mu0 = 0, tau2 = 10, sigma2 = 1, seed = 42)

Arguments

y

Observations.

alpha

Concentration, strictly positive.

n_iter

Number of full sweeps.

mu0, tau2

Base measure N(mu0, tau2) for the cluster means.

sigma2

Known within-cluster variance.

seed

Seed of the deterministic stream.

Value

List with estimate (number of clusters), z, counts, cluster_mean, n_clusters, loglik, n, method.

Details

P(z_i = k | .) proportional to n_k^{-i} f(y_i | y_{-i,k}) and to alpha f(y_i) for a new table, with the normal-normal predictive density in closed form. Marginalising theta is what collapses the sampler: no cluster parameters are ever stored.

References

MacEachern (1994), Commun. Statist. B 23(3):727-741; Neal (2000), J. Comput. Graph. Statist. 9(2):249-265, algorithm 3.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Crpcol(V)
#> $estimate
#> [1] 3
#> 
#> $z
#> [1] 1 1 1 2 0 0 0 0
#> 
#> $counts
#> [1] 4 3 1
#> 
#> $cluster_mean
#> [1] 6.341463 1.935484 3.636364
#> 
#> $n_clusters
#> [1] 3
#> 
#> $loglik
#> [1] -10.97414
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "collapsed Gibbs sampler for a CRP mixture"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"