Learn R Programming

SSLfmm (version 0.1.0)

get_clusterprobs: Posterior Cluster Probabilities for a Gaussian Mixture

Description

Compute posterior membership probabilities \(\tau_{ij}\) for each observation under a Gaussian mixture with either a shared covariance matrix or component-specific covariances.

Usage

get_clusterprobs(
  dat,
  n,
  p,
  g,
  pi = NULL,
  mu = NULL,
  sigma = NULL,
  paralist = NULL
)

Value

Numeric matrix \(n \times g\) of posterior probabilities \(\tau_{ij}\).

Arguments

dat

Numeric matrix \(n \times p\). Data matrix (rows = observations).

n

Integer. Number of observations (checked against nrow(dat)).

p

Integer. Number of variables (checked against ncol(dat)).

g

Integer. Number of components.

pi

Optional numeric vector length \(g\). Mixing proportions (sum to 1).

mu

Optional numeric matrix \(p \times g\). Column \(i\) is mean of component \(i\).

sigma

Optional numeric matrix \(p \times p\) (shared covariance) or array \(p \times p \times g\) (component-specific covariances).

paralist

Optional list with elements pi, mu, sigma. If provided, these take precedence over the corresponding explicit args.

Examples

Run this code
  n <- 100; p <- 2; g <- 2
  X <- matrix(rnorm(n*p), n, p)
  pi <- c(0.6, 0.4)
  mu <- cbind(c(0,0), c(1,1))
  Sig <- array(0, dim = c(p,p,g)); Sig[,,1] <- diag(p); Sig[,,2] <- diag(p)
  tau <- get_clusterprobs(X, n, p, g, pi = pi, mu = mu, sigma = Sig)
  head(tau)

Run the code above in your browser using DataLab