# simdata_normal: Generates random variates from K multivariate normal... In sortinghat: sortinghat

## Description

We generate n_k observations (k = 1, …, K) from each of K multivariate normal distributions. Let the kth population have a p-dimensional multivariate normal distribution, N_p(μ_k, Σ_k) with mean vector μ_k and positive-definite covariance matrix Σ_k.

## Usage

 `1` ``` simdata_normal(n, mean, cov, seed = NULL) ```

## Arguments

 `n` a vector (of length K) of the sample sizes for each population `mean` a vector or a list (of length K) of mean vectors `cov` a symmetric matrix or a list (of length K) of symmetric covariance matrices. `seed` seed for random number generation (If `NULL`, does not set seed)

## Details

The number of populations, `K`, is determined from the length of the vector of sample sizes, coden. The mean vectors and covariance matrices each can be given in a list of length `K`. If one covariance matrix is given (as a matrix or a list having 1 element), then all populations share this common covariance matrix. The same logic applies to population means.

## Value

named list containing:

x:

A matrix whose rows are the observations generated and whose columns are the `p` features (variables)

y:

A vector denoting the population from which the observation in each row was generated.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18``` ```# Generates 10 observations from each of two multivariate normal populations # with equal covariance matrices. mean_list <- list(c(1, 0), c(0, 1)) cov_identity <- diag(2) data_generated <- simdata_normal(n = c(10, 10), mean = mean_list, cov = cov_identity, seed = 42) dim(data_generated\$x) table(data_generated\$y) # Generates 10 observations from each of three multivariate normal # populations with unequal covariance matrices. set.seed(42) mean_list <- list(c(-3, -3), c(0, 0), c(3, 3)) cov_list <- list(cov_identity, 2 * cov_identity, 3 * cov_identity) data_generated2 <- simdata_normal(n = c(10, 10, 10), mean = mean_list, cov = cov_list) dim(data_generated2\$x) table(data_generated2\$y) ```

sortinghat documentation built on May 30, 2017, 4:52 a.m.