1
$\begingroup$

I would like to draw samples from a multivariate mixture model, for a given value of one of the variables.

Assuming a gaussian mixture distribution built on $P_{1..p}$ variables with $K$ components:

$$f(x) = \sum_{i = 1}^K\pi_iN(\mu_i,\Sigma_i)$$

I need to draw samples from:

$$x|P_j=z,P_{\setminus j} \sim \sum_{i = 1}^K\pi_iN(\mu_{i,\setminus j},\Sigma_{i,\setminus j})$$

with $\mu_{i,\setminus j},\Sigma_{i,\setminus j}$ to be restimated in the $p-1$ parameter space. (I hope the formalization was correct)

If there is an R solution based on the package mclust I'd be happier, otherwise I try to make my way in the math.

UPDATE: I found a very raw workaround in R: I estimate the weighted multivariate density from a mixture model for a (dense) grid in which one parameter is fixed and the others vary along their range. Then I sample from this grid with probability given by the density.

Example for a 2-dimensional parameter space:

library(dplyr)
library(mclust)

dens <- densityMclust(iris[,1:2])
z = 5.2
grid <- tibble(
    x = seq(min(iris$Sepal.Width), max(iris$Sepal.Width), length.out = 20000),
    d = sapply(1:dens$G, function(i) dens$parameters$pro[i] * dmvnorm(data.frame(z, x), dens$parameters$mean[,i], dens$parameters$variance$sigma[,,i])) %>% rowSums()
)

out <- sample(grid$x, 1000, replace = T, prob = grid$d)

plot(grid, type = 'l')
plot(density(out))

Of course is not very efficient to do this for every value of $P_j$ of interest. Also the final density is not a continuous function; I could estimate a new mixture model on the $p - 1$ grid after resampling, but that would be even less efficient.

The optimal solution would be to estimate the component parameters of the $P_j = z$ conditional $p - 1$ parameter space directly from the initial $p$ dimensional mixture model analytically.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.