Skip to contents

Formula: P(z_i | z_{-i}) proportional to n_k^{-i} f(y_i | theta_k), and to (alpha/m) f(y_i | theta_aux) for each of m auxiliary draws

Usage

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

Arguments

y

Observations.

alpha

Concentration, strictly positive.

n_iter

Number of sweeps.

m

Number of auxiliary components.

mu0, tau2

Base measure N(mu0, tau2).

sigma2

Known within-cluster variance.

seed

Seed of the deterministic stream.

Value

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

Details

Neal's algorithm 8: the cluster parameters are kept explicit rather than integrated out, and m fresh draws from the base measure stand in for the infinitely many empty tables. That makes the sampler valid for non-conjugate base measures, unlike the collapsed algorithm 3; here the conjugate normal case is used so the two can be compared.

References

Neal (2000), J. Comput. Graph. Statist. 9(2):249-265, algorithm 8.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Crpgib(V)
#> $estimate
#> [1] 3
#> 
#> $z
#> [1] 1 1 1 2 0 0 0 0
#> 
#> $counts
#> [1] 4 3 1
#> 
#> $theta
#> [1] 6.811173 2.500116 3.922563
#> 
#> $n_clusters
#> [1] 3
#> 
#> $loglik
#> [1] -11.42334
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "CRP Gibbs sampler, Neal algorithm 8"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"