update_classes_dp: Dirichlet process class updates

View source: R/RcppExports.R

update_classes_dpR Documentation

Dirichlet process class updates

Description

Dirichlet process class updates

Usage

update_classes_dp(
  beta,
  z,
  b,
  Omega,
  delta,
  mu_b_0,
  Sigma_b_0,
  n_Omega_0,
  V_Omega_0,
  identify_classes = FALSE,
  Cmax = 10L
)

Arguments

beta

[matrix(nrow = P_r, ncol = N)]
The matrix of the decider-specific coefficient vectors.

z

[numeric(N)]
The decider class allocations.

b

[matrix(nrow = P_r, ncol = C)]
The matrix of class means as columns.

Omega

[matrix(nrow = P_r * P_r, ncol = C)]
The matrix of vectorized class covariance matrices as columns.

delta

[numeric(1)]
The prior concentration for s.

mu_b_0

[numeric(P_r)]
The mean vector of the normal prior for each b_c.

Sigma_b_0

[matrix(P_r, P_r)]
The covariance matrix of the normal prior for each b_c.

n_Omega_0

[integer(1)]
The degrees of freedom of the Inverse Wishart prior for each Omega_c.

V_Omega_0

[matrix(P_r, P_r)]
The scale matrix of the Inverse Wishart prior for each Omega_c.

identify_classes

[logical(1)]
Identify classes by decreasing class weights?

Cmax

[integer(1)]
The maximum number of classes, used to allocate space.

Value

A list of updated values for z, b, Omega, and C.

Examples

set.seed(1)
z <- c(rep(1, 10),rep(2, 10))
b <- matrix(c(5, 5, 5, -5), ncol = 2)
Omega <- matrix(c(1, 0.3, 0.3, 0.5, 1, -0.3, -0.3, 0.8), ncol = 2)
beta <- sapply(
  z, function(z) oeli::rmvnorm(n = 1, b[, z], matrix(Omega[, z], 2, 2))
)
beta[, 1] <- c(-10, 10)
update_classes_dp(
  beta = beta, z = z, b = b, Omega = Omega,
  delta = 1, mu_b_0 = numeric(2), Sigma_b_0 = diag(2),
  n_Omega_0 = 4, V_Omega_0 = diag(2)
)


RprobitB documentation built on Aug. 26, 2025, 1:08 a.m.