generate_specific_shape_sparse_cov_matrix {Glarmadillo}R Documentation

Generate Specific Shape Sparse Covariance Matrix

Description

Generates a covariance matrix and corresponding data matrix (Y) with a specific shape defined by a given shape matrix (M). This function is particularly useful for simulating data with predefined covariance structures, facilitating the testing of statistical methods such as sparse covariance estimation.

Usage

generate_specific_shape_sparse_cov_matrix(n, p, M)

Arguments

n

The number of variables (rows of Y and dimensions of M).

p

The number of samples (columns of Y).

M

The shape matrix used to define the structure of the covariance matrix. Must be a positive definite square matrix of size n x n.

Value

A list containing two elements: - Y: A n by p data matrix, where each column represents a sample, and each row represents a variable. - cov_Y: The n by n covariance matrix of the transposed data matrix Y. This covariance matrix reflects the structure imposed by the shape matrix M.

Examples

# Generate a 10x10 specific shape sparse covariance matrix
shape_matrix <- matrix(rnorm(100), 10, 10)
shape_matrix <- shape_matrix %*% t(shape_matrix) # Making it positive definite
result <- generate_specific_shape_sparse_cov_matrix(n = 10, p = 5, M = shape_matrix)
Y <- result$Y
cov_Y <- result$cov_Y


[Package Glarmadillo version 1.1.1 Index]