covariance_matrix: Create Covariance Matrix

View source: R/simulate_data_baseline.R

covariance_matrixR Documentation

Create Covariance Matrix

Description

Create Covariance Matrix

Usage

covariance_matrix(diag, upper_tri)

Arguments

diag

Diagonal entries of the covariance matrix

upper_tri

Upper triangle entries of the matrix, specified column wise.

Value

A symmetric matrix with diag values on the main diagonal and upper_tri values in the lower and upper triangles.

Examples

m1 <- covariance_matrix(c(1, 1, 1, 1), c(.8, .3, .8, 0, 0, 0))
m1
mvtnorm::rmvnorm(5, mean = c(0, 0, 0, 0), sigma = m1)

# No correlation
covariance_matrix(c(1, 2, 3))


psborrow2 documentation built on April 4, 2025, 12:37 a.m.