update_z: Update class allocation vector

View source: R/RcppExports.R

update_zR Documentation

Update class allocation vector

Description

This function updates the class allocation vector (independently for all observations) by drawing from its conditional distribution.

Usage

update_z(s, beta, b, Omega)

Arguments

s

The vector of class weights of length C. Set to NA if P_r = 0. For identifiability, the vector must be non-ascending.

beta

The matrix of the decision-maker specific coefficient vectors of dimension P_r x 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.

Details

Let z = (z_1,\dots,z_N) denote the class allocation vector of the observations (mixed coefficients) \beta = (\beta_1,\dots,\beta_N). Independently for each n, the conditional probability \Pr(z_n = c \mid s,\beta_n,b,\Omega) of having \beta_n allocated to class c for c=1,\dots,C depends on the class allocation vector s, the class means b=(b_c)_c and the class covariance matrices Omega=(Omega_c)_c and is proportional to

s_c \phi(\beta_n \mid b_c,Omega_c).

Value

An updated class allocation vector.

Examples

### class weights for C = 2 classes
s <- rdirichlet(c(1,1))
### coefficient vector for N = 1 decider and P_r = 2 random coefficients
beta <- matrix(c(1,1), ncol = 1)
### class means and covariances
b <- cbind(c(0,0),c(1,1))
Omega <- cbind(c(1,0,0,1),c(1,0,0,1))
### updated class allocation vector
update_z(s = s, beta = beta, b = b, Omega = Omega)

RprobitB documentation built on May 29, 2024, 7:59 a.m.