Learn R Programming

SynthesizerPlus (version 0.4.0)

make_corr: Build a correlation matrix with a given structure

Description

Build a correlation matrix with a given structure

Usage

make_corr(
  d,
  type = c("exchangeable", "ar1", "toeplitz", "random", "identity"),
  rho = 0.5,
  names = NULL
)

Value

A d x d correlation matrix.

Arguments

d

Dimension.

type

Structure: "exchangeable" (all off-diagonal entries rho), "ar1" (rho^|i-j|), "toeplitz" (first row given by rho, a vector of length d - 1), "random" (a random positive-definite correlation matrix) or "identity".

rho

Correlation parameter (see type).

names

Optional variable names.

Examples

Run this code
make_corr(4, "ar1", rho = 0.7)
make_corr(3, "toeplitz", rho = c(0.5, 0.2))

Run the code above in your browser using DataLab