View source: R/main_functions.R
rconstr0_GMM | R Documentation |
This function will simulate data from a GMM with n data points divided up between the number of clusters determined by the number of entries in prop. Observations from a single replicate are assumed to have mean mu and variance sigma. The data have dimension d (number of replicates), and number of components h (number of possible classifications, for a given replicate). Two replicates from the same component have correlation rho. If two replicates are from different components, their correlation is 0. In rconstr_GMM
, all clusters have the same mean and correlation, up to a sign. Here, means and correlations are not necessarily equal, but must satisfy sign constraints. Variances also are permitted to vary.
rconstr0_GMM(n, prop, mu, sigma, rho, d, combos = NULL)
n |
The number of observations. |
prop |
The proportion of data that belong to each cluster. The length of prop must equal the correct number of clusters. If prop doesn't sum to 1, it is normalized to do so. |
mu |
Numeric 2-vector corresponding to the means of the negative, positive association components. The first element must be negative and the second must be positive. |
sigma |
Numeric 2-vector corresponding to the variances of the negative, positive association components. |
rho |
Numeric 3-vector corresponding to the correlation between two negative/cross/two possitive components. The first and third elements must be positive, the second must be negative. |
d |
Number of replicates. |
combos |
M by d ternary matrix determining which association labels to retain (defaults to all possible configurations). |
data |
An n by d numeric matrix of simulated multivariate normal data, where d is the dimension of the data. |
cluster |
Integer vector of the true cluster labels. |
params |
List of parameters supplied for simulation. |
rGMM, rconstr_GMM
set.seed(123) pal <- sample(get_pals(4), 9, replace = FALSE) sim <- rconstr0_GMM(3000, rep(1/9, 9), c(-2,3), c(.9,.9), c(.8,-.5,.7), 2) plot(sim$data, col = pal[sim$cluster])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.