Description Usage Arguments Details Value Author(s) Source See Also Examples
Simulate correlated continuaous data from standard normal distribution by using Choleski factorization of correlation matrix.
1 | simCorrVars(corrMat, N = 100)
|
corrMat |
A symmetricmatrix of correlation coefficients. Determinant of
|
N |
A number of observations. Default is 100. |
Number of variables is determined by the size of correlation matrix
corrMat
.
A dataframe with correlated variables.
Vilmantas Gegzna
http://www.r-bloggers.com/simulating-random-multivariate-correlated-data-continuous-variables/
corr_vec2mat
, mvrnorm, chol
Other simmulation functions in spMisc:
corr_vec2mat()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # ------------------------------------------------------------
simCorrVars()
simCorrVars(N = 10)
# ------------------------------------------------------------
# Generate 2 correlated variables with 10 observations:
# A. Imput is a matrix
corrMat <- matrix(c(1, .5, .5, 1), 2)
print(corrMat)
simCorrVars(corrMat, N = 10)
# B. Imput is a vector
simCorrVars(.5, N = 10)
simCorrVars(c(.1,.5,.8), N = 10)
# ------------------------------------------------------------
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.