Learn R Programming

nethet (version 1.4.2)

sim_mix: Simulate from mixture model.

Description

Simulate from mixture model with multi-variate Gaussian or t-distributed components.

Usage

sim_mix(n, n.comp, mix.prob, Mu, Sig, dist = "norm", df = 2)

Arguments

n
sample size
n.comp
number of mixture components ("comps")
mix.prob
mixing probablities (need to sum to 1)
Mu
matrix of component-specific mean vectors
Sig
array of component-specific covariance matrices
dist
'norm' for Gaussian components, 't' for t-distributed components
df
degrees of freedom of the t-distribution (not used for Gaussian distribution), default=2

Value

  • a list consisting of:
  • Scomponent assignments
  • Xobserved data matrix

Examples

Run this code
n.comp = 4
p = 5 # dimensionality
Mu = matrix(rep(0, p), p, n.comp)
Sigma = array(diag(p), c(p, p, n.comp))
mix.prob = rep(0.25, n.comp)

sim_mix(100, n.comp, mix.prob, Mu, Sigma)

Run the code above in your browser using DataLab