Learn R Programming

abnormality (version 0.1.0)

generate_correlated_matrix: Generate a matrix of correlated variables

Description

Generate a matrix of correlated variables

Usage

generate_correlated_matrix(n, p, corr, constant_cov_matrix = T, mean = 0)

Arguments

n

number of observations

p

number of features/variables

corr

the correlation coefficient (-1 < r < 1)

constant_cov_matrix

should the value of corr be constant in the covariance matrix, or should corr be the average value in the covariance matrix.

mean

the mean value of the generated variables.

Value

an n x p matrix

Examples

Run this code
# NOT RUN {
Subject <- generate_correlated_matrix(1, 100, corr = .75,constant_cov_matrix = TRUE)
Reference_Population <- generate_correlated_matrix(100, 100, corr = .75,constant_cov_matrix = TRUE)
# }

Run the code above in your browser using DataLab