sim_cor_mat: Simulate a correlation matrix from a given nb of variables

Description Usage Arguments Details Value Examples

View source: R/create_covcor.R

Description

Simulate a correlation matrix from a given nb of variables.

Usage

1
sim_cor_mat(nvars = 2, is_cor = TRUE)

Arguments

nvars

Positive number of variables, must be >= 2.

is_cor

TRUE (default): Return the correlation matrix. FALSE: return the covariance matrix.

Details

Simulate a correlation matrix from a given nb of variables by creating a covariance matrix and transforming it to a correlation matrix with stats::cov2cor. The method was copied from simstudy::genCorMat() to whom I express my gratitude.

Value

Correlation matrix nvars x nvars

Examples

1
2
mat <- sim_cor_mat(4)
stopifnot(identical(dim(mat), c(4L, 4L)))

FrankLef/eflStats documentation built on Dec. 17, 2021, 8:30 p.m.