Learn R Programming

covKCD (version 0.1)

cm2ca: Covariance matrix to covariance array

Description

Reshape a covariance matrix to a covariance array.

Usage

cm2ca(S, p1, p2)

Value

a four-way array where entry i1,j1,i2,j2 gives the covariance between element i1,j1 and element i2,j2 of a random matrix.

Arguments

S

a covariance matrix of dimension (p1p2)*(p1p2).

p1

the row dimension.

p2

the column dimension.

Author

Peter Hoff

Examples

Run this code
p1<-4 ; p2<-7 ; p<-p1*p2 
 
S<-rWishart(1,p,diag(p))[,,1] 
A<-cm2ca(S,p1,p2) 
range(S-ca2cm(A)) 

Run the code above in your browser using DataLab