This function updates the latent classes based on a Dirichlet process.

## Usage

update_classes_dp(
Cmax,
beta,
z,
b,
Omega,
delta,
xi,
D,
nu,
Theta,
s_desc = TRUE
)

## Arguments

Cmax

The maximum number of classes.

beta

The matrix of the decision-maker specific coefficient vectors of dimension P_r x N. Set to NA if P_r = 0.

z

The vector of the allocation variables of length N. Set to NA if P_r = 0.

b

The matrix of class means as columns of dimension P_r x C. Set to NA if P_r = 0.

Omega

The matrix of class covariance matrices as columns of dimension P_r*P_r x C. Set to NA if P_r = 0.

delta

A numeric for the concentration parameter vector rep(delta,C) of the Dirichlet prior for s. Per default, delta = 1. In case of Dirichlet process-based updates of the latent classes, delta = 0.1 per default.

xi

The mean vector of length P_r of the normal prior for each b_c. Per default, xi = numeric(P_r).

D

The covariance matrix of dimension P_r x P_r of the normal prior for each b_c. Per default, D = diag(P_r).

nu

The degrees of freedom (a natural number greater than P_r) of the Inverse Wishart prior for each Omega_c. Per default, nu = P_r + 2.

Theta

The scale matrix of dimension P_r x P_r of the Inverse Wishart prior for each Omega_c. Per default, Theta = diag(P_r).

s_desc

If TRUE, sort the classes in descending class weight.

## Value

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

## Examples

set.seed(1)
z <- c(rep(1,20),rep(2,30))
b <- matrix(c(1,1,1,-1), 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) rmvnorm(b[,z], matrix(Omega[,z],2,2)))
delta <- 1
xi <- numeric(2)
D <- diag(2)
nu <- 4
Theta <- diag(2)
RprobitB:::update_classes_dp(
Cmax = 10, beta = beta, z = z, b = b, Omega = Omega,
delta = delta, xi = xi, D = D, nu = nu, Theta = Theta
)
#> $z #> [,1] #> [1,] 2 #> [2,] 2 #> [3,] 2 #> [4,] 2 #> [5,] 2 #> [6,] 2 #> [7,] 1 #> [8,] 2 #> [9,] 2 #> [10,] 2 #> [11,] 2 #> [12,] 1 #> [13,] 2 #> [14,] 2 #> [15,] 2 #> [16,] 2 #> [17,] 2 #> [18,] 3 #> [19,] 1 #> [20,] 2 #> [21,] 1 #> [22,] 1 #> [23,] 1 #> [24,] 1 #> [25,] 1 #> [26,] 1 #> [27,] 1 #> [28,] 1 #> [29,] 1 #> [30,] 1 #> [31,] 1 #> [32,] 1 #> [33,] 1 #> [34,] 3 #> [35,] 2 #> [36,] 1 #> [37,] 1 #> [38,] 1 #> [39,] 1 #> [40,] 1 #> [41,] 1 #> [42,] 1 #> [43,] 1 #> [44,] 1 #> [45,] 1 #> [46,] 1 #> [47,] 1 #> [48,] 1 #> [49,] 1 #> [50,] 3 #> #>$b
#>            [,1]     [,2]       [,3]
#> [1,]  1.1955613 1.381324 -0.4912123
#> [2,] -0.9791527 1.218404  0.4543349
#>
#> $Omega #> [,1] [,2] [,3] #> [1,] 0.7161232 0.4793177 0.37048920 #> [2,] -0.1869330 0.1085593 -0.03874837 #> [3,] -0.1869330 0.1085593 -0.03874837 #> [4,] 0.5616673 0.2745555 0.37381786 #> #>$s
#> [1] 0.60 0.34 0.06
#>
#> \$C
#> [1] 3
#>