correlation_matrix: Construct correlation matrix

View source: R/correlate.R

correlation_matrixR Documentation

Construct correlation matrix

Description

Given a set of values, convert it to a correlation matrix.

Usage

correlation_matrix(
  ...,
  .names = NULL,
  .upper = NULL,
  .byrow = TRUE,
  .check = TRUE
)

Arguments

...

A series of values or dots for the correlation matrix. Only the value in the upper triangle or lower triangle (not both) should be used. Use . for value of 1 in the diagonal entries and value of 0 in off-diagonal entries. For a n x n correlation matrix, there should be n x n values.

.names

The name of the variables.

.upper

A vector of values for the upper triangle values filled by row (or column if .byrow = FALSE. If .upper is defined then ... is ignored.

.byrow

A logical value indicating whether the matrix is filled by row or column. The default is TRUE.

.check

A logical value to indicate if the correlation matrix is valid or not. This essentially equates to check that the matrix is semi-positive definite.

See Also

cor_matrix_str

Other correlation matrix: cor_matrix_str()

Examples

correlation_matrix(., 0.7, .,   .,
                   .,   ., ., 0.3,
                   .,   ., .,   .,
                   .,   ., .,   .)

correlation_matrix(.upper = c(0.7, 0.1, 0.3, 0.2, -0.1, -0.3))

correlation_matrix(.upper = c(0.7, 0.1, 0.3, 0.2, -0.1, -0.3),
                   .byrow = FALSE)

correlation_matrix(.upper = rep(0.2, 3), .names = c("A", "B", "C"))


emitanaka/simulate documentation built on July 1, 2022, 9:32 a.m.