Generate Non-normal Data using Vale and Maurelli (1983) method. The function
is designed to be as similar as the popular mvrnorm
function in the
MASS
package. The codes are copied from mvrnorm
function in
the MASS
package for argument checking and lavaan
package for
data generation using Vale and Maurelli (1983) method.
mvrnonnorm(n, mu, Sigma, skewness = NULL, kurtosis = NULL, empirical = FALSE)
Sample size
A mean vector. If elements are named, those will be used as variable names in the returned data matrix.
A positive-definite symmetric matrix specifying the covariance
matrix of the variables. If rows or columns are named (and mu
is
unnamed), those will be used as variable names in the returned data matrix.
A vector of skewness of the variables
A vector of excessive kurtosis of the variables
If TRUE
, mu
and Sigma
specify the
empirical rather than population mean and covariance matrix
A data matrix
Vale, C. D. & Maurelli, V. A. (1983). Simulating multivariate nonormal distributions. Psychometrika, 48(3), 465--471. doi:10.1007/BF02293687
# NOT RUN {
set.seed(123)
mvrnonnorm(20, c(1, 2), matrix(c(10, 2, 2, 5), 2, 2),
skewness = c(5, 2), kurtosis = c(3, 3))
## again, with variable names specified in mu
set.seed(123)
mvrnonnorm(20, c(a = 1, b = 2), matrix(c(10, 2, 2, 5), 2, 2),
skewness = c(5, 2), kurtosis = c(3, 3))
# }
Run the code above in your browser using DataLab