Learn R Programming

mixedCCA (version 1.6.2)

CorrStructure: Construct a correlation matrix

Description

Functions to create autocorrelation matrix (p by p) with parameter rho and block correlation matrix (p by p) using group index (of length p) and (possibly) different parameter rho for each group.

Usage

autocor(p, rho)

blockcor(blockind, rho)

Arguments

p

Specified matrix dimension.

rho

Correlation value(s), must be between -0.99 and 0.99. Should be a scalar for autocor, and either a scalar or a vector of the same length as the maximal blockind K for blockcor.

blockind

Block index 1,..., K for a positive integer K specifying which variable belongs to which block, the matrix dimension is equal to length(blockind).

Examples

Run this code
# For p = 8,
# auto correlation matrix
autocor(8, 0.8)
# block correlation matrix: two blocks with the same correlation within each block
blockcor(c(rep(1,3), rep(2,5)), 0.8)
# block correlation matrix: two blocks with different correlation within each block
blockcor(c(rep(1,3), rep(2,5)), c(0.8, 0.3))

Run the code above in your browser using DataLab