Skip to contents

Formula: G ~ DP(alpha, G_0); theta_i | G ~ G; y_i ~ f(theta_i)

Usage

Dpmem(
  y,
  alpha = 1,
  base_distribution = NULL,
  n_iter = 50,
  sigma2 = 1,
  seed = 42
)

Arguments

y

Observations.

alpha

Concentration, strictly positive.

base_distribution

(mu0, tau2) of the normal base measure, or NULL for (0, 10).

n_iter

Number of sweeps.

sigma2

Known within-cluster variance.

seed

Seed of the deterministic stream.

Value

List with estimate (posterior predictive mean), n_clusters, z, counts, cluster_mean, weights, w_new, loglik, n, method.

Details

Fitted by the collapsed Gibbs sampler with a normal base measure and a known within-cluster variance. Because theta is integrated out, the single-cluster case reduces exactly to the conjugate normal posterior mean (mu0/tau2 + sum y/sigma2) / (1/tau2 + n/sigma2), the degenerate check the fit has to reproduce.

References

Antoniak (1974), Ann. Statist. 2(6):1152-1174; Escobar & West (1995), JASA 90(430):577-588; Neal (2000), J. Comput. Graph. Statist. 9(2):249-265.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Dpmem(V)
#> $estimate
#> [1] 3.86763
#> 
#> $n_clusters
#> [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
#> 
#> $weights
#> [1] 0.4444444 0.3333333 0.1111111
#> 
#> $w_new
#> [1] 0.1111111
#> 
#> $loglik
#> [1] -10.97414
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "Dirichlet process mixture, collapsed Gibbs"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"