rmvnormmix {mixtools} | R Documentation |
Simulate from Multivariate (repeated measures) Mixtures of Normals
Description
Simulate from a mixture of multivariate zero-correlation normal distributions
Usage
rmvnormmix(n, lambda=1, mu=0, sigma=1)
Arguments
n |
Number of cases to simulate. |
lambda |
Vector of mixture probabilities with length equal to |
mu |
Matrix of means of dimensions |
sigma |
Matrix of standard deviations, same dimensions as |
Details
It is possible to generate univariate standard normal random variables using the default values (but why bother?). The case of conditionally iid coordinates is covered by the situation in which all columns in mu and sigma are identical.
Value
rmvnormmix
returns an n\times r
matrix in which each row is
a sample from one of the components of a mixture of zero-correlation
multivariate normals. The mixture structure
induces nonzero correlations among the coordinates.
See Also
Examples
##Generate data from a 2-component mixture of trivariate normals.
set.seed(100)
n <- 200
lambda <- rep(1, 2)/2
mu <- matrix(2*(1:6), 2, 3)
sigma <- matrix(1,2,3)
mydata<-rmvnormmix(n, lambda, mu, sigma)
## Now check to see if we can estimate mixture densities well:
title <- paste("Does this resemble N(", mu[1,], ",1) and N(", mu[2,],",1)?",
sep="")
plot(npEM(mydata, 2), title=title)