Learn R Programming

umx (version 4.9.0)

umx_make_raw_from_cov: Turn a cov matrix into raw data

Description

A wrapper for MASS::mvrnorm() to simplify turning a covariance matrix into matching raw data.

Usage

umx_make_raw_from_cov(covMat, n, means = 0, varNames = NULL, empirical = FALSE)

Arguments

covMat

A covariance matrix

n

How many rows of data to return

means

the means of the raw data (default = 0)

varNames

default uses "var1", "var2"

empirical

(passed to mvrnorm) Default = FALSE

Value

  • data.frame

References

See Also

Other Data Functions: umxFactor(), umxHetCor(), umx_as_numeric(), umx_cont_2_quantiles(), umx_lower2full(), umx_make_MR_data(), umx_make_TwinData(), umx_make_fake_data(), umx_polychoric(), umx_polypairwise(), umx_polytriowise(), umx_read_lower(), umx_read_prolific_demog(), umx_rename(), umx_reorder(), umx_score_scale(), umx_select_valid(), umx_stack(), umx

Examples

Run this code
# NOT RUN {
covData <- matrix(nrow=6, ncol=6, byrow=TRUE, dimnames=list(paste0("v", 1:6), paste0("v", 1:6)),
  data = c(0.9223099, 0.1862938, 0.4374359, 0.8959973, 0.9928430, 0.5320662,
           0.1862938, 0.2889364, 0.3927790, 0.3321639, 0.3371594, 0.4476898,
           0.4374359, 0.3927790, 1.0069552, 0.6918755, 0.7482155, 0.9013952,
           0.8959973, 0.3321639, 0.6918755, 1.8059956, 1.6142005, 0.8040448,
           0.9928430, 0.3371594, 0.7482155, 1.6142005, 1.9223567, 0.8777786,
           0.5320662, 0.4476898, 0.9013952, 0.8040448, 0.8777786, 1.3997558)
)

myData = umx_make_raw_from_cov(covData, n = 100, means = 1:6)
umxAPA(myData)
covMat = matrix(c(1, .3, .3, 1), nrow=2)
tmp= umx_make_raw_from_cov(covMat, n=10, varNames= c("x", "y"))
cov(tmp)
tmp= umx_make_raw_from_cov(covMat, n=10, varNames= c("x", "y"), empirical= TRUE)
cov(tmp)
tmp= umx_make_raw_from_cov(qm(1, .3| .3, 1), n=10, varNames= c("x", "y"))
cov(tmp)
# }

Run the code above in your browser using DataLab