Learn R Programming

RBesT (version 1.8-2)

mixmvnorm: Multivariate Normal Mixture Density

Description

The multivariate normal mixture density and auxiliary functions.

Usage

mixmvnorm(..., sigma, param = c("ms", "mn", "msr"))

msr2mvnorm(m, s, r, unlist = TRUE)

# S3 method for mvnormMix print(x, ...)

# S3 method for mvnormMix summary(object, ...)

# S3 method for mvnormMix sigma(object, ...)

Value

Returns a multivariate normal mixture with the specified mixture components.

Arguments

...

List of mixture components.

sigma

Reference covariance.

param

Determines how the parameters in the list are interpreted. See details.

m

Mean vector.

s

Standard deviation vector.

r

Vector of correlations in column-major format of the lower triangle of the correlation matrix.

unlist

Logical. Controls whether the result is a flattened vector (TRUE) or a list with mean m and covariance s (FALSE). Defaults to TRUE.

object, x

Multivariate normal mixture object.

Details

Each entry in the ... argument list is a numeric vector defining one component of the mixture multivariate normal distribution. The first entry of the component defining vector is the weight of the mixture component followed by the vector of means in each dimension and finally a specification of the covariance matrix, which depends on the chosen parametrization. The covariance matrix is expected to be given as numeric vector in a column-major format, which is standard conversion applied to matrices by the vector concatenation function base::c(). Please refer to the examples section below.

Each component defining vector can be specified in different ways as determined by the param option:

ms

Mean vector and covariance matrix s. Default.

mn

Mean vector and number of observations. n determines the covariance for each component via the relation \(\Sigma/n\) with \(\Sigma\) being the known reference covariance.

msr

Mean vector, standard deviations and correlations in column-major format (corresponds to order when printing multi-variate normal mixtures).

The reference covariance \(\Sigma\) is the known covariance in the normal-normal model (observation covariance). The function sigma can be used to query the reference covariance and may also be used to assign a new reference covariance, see examples below. In case sigma is not specified, the user has to supply sigma as argument to functions which require a reference covariance.

See Also

Other mixdist: mix, mixbeta(), mixcombine(), mixgamma(), mixjson, mixnorm(), mixplot

Examples

Run this code

# default mean & covariance parametrization
S <- diag(c(1, 2)) %*% matrix(c(1, 0.5, 0.5, 1), 2, 2) %*% diag(c(1, 2))
mvnm1 <- mixmvnorm(
  rob = c(0.2, c(0, 0), diag(c(2, 2)^2)),
  inf = c(0.8, c(0.5, 1), S / 4), sigma = S
)

print(mvnm1)
summary(mvnm1)

set.seed(657846)
mixSamp1 <- rmix(mvnm1, 500)
colMeans(mixSamp1)

# alternative mean, sd and correlation parametrization
mvnm1_alt <- mixmvnorm(
  rob = c(0.2, c(0, 0), c(2, 2), 0.0),
  inf = c(0.8, c(0.5, 1), c(1, 2) / 2, 0.5),
  sigma = msr2mvnorm(s = c(1, 2), r = 0.5, unlist = FALSE)$s,
  param = "msr"
)

print(mvnm1_alt)

Run the code above in your browser using DataLab