create_corr: Create a covariance/correlation matrix

Description Usage Arguments Details Examples

View source: R/create_corr.R

Description

Creates a correlation or covariance matrix given a vector of values for the lower triangle.

Usage

1
create_corr(x, diagonal = NULL)

Arguments

x

A numeric vector

diagonal

A vector of variances

Details

This function takes the provided values and creates a symmetric (covariance) matrix, e.g. for simulation or demonstration purposes. The values are filled column-wise in the lower triangle first. For example mat[1,2] = x[1], mat[1,3] = x[2] and so on.

Examples

1
2
3
4
5
library(lazerhawk)
cors = runif(6, -1, 1)
create_corr(cors)
covs = runif(3, 1, 5)
create_corr(covs, diag=c(1,2,3))

mclark--/lazerhawk documentation built on July 17, 2018, 3:11 a.m.