Learn R Programming

AdapDiscom (version 1.0.0)

generate.cov: Generate Covariance Matrix

Description

Generate Covariance Matrix

Usage

generate.cov(p, example)

Value

A p x p covariance matrix

Arguments

p

Integer, dimension of the covariance matrix

example

Integer, type of covariance structure (1=AR(1), 2=Block diagonal, 3=Kronecker product)

Examples

Run this code
# AR(1) covariance structure
Sigma1 <- generate.cov(p = 20, example = 1)
print(Sigma1[1:3, 1:3])

# Block diagonal structure (p must be multiple of 5)
Sigma2 <- generate.cov(p = 25, example = 2) 
print(Sigma2[1:5, 1:5])

# Kronecker product structure (p must be multiple of 10)
Sigma3 <- generate.cov(p = 100, example = 3)
print(dim(Sigma3))

Run the code above in your browser using DataLab