Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

random.pm

Random square definite positive matrix


Description

Generate a random definite positive matrix with specified dimension

Usage

random.pm(n, values)

Arguments

n

Dimension of matrix

values

(Optional) A numeric vector of dimension n : the eigenvalues of the matrix

Details

If values isn't given, it is chosen (deterministically) so that the eigenvalues of the resulting matrix are similar to eigenvalues observed on Genetic Relationship Matrices.

The random matrix is generated as U %*% diag(values) %*% t(U) with U a random orthogonal matrix.

Value

A named list with members:

K

A n x n symmetric positive matrix

eigen

The eigen decomposition of K as eigen(K) would output it

See Also

Examples

# generate a random positive matrix 
set.seed(1)
R <- random.pm(500)
str(R)

gaston

Genetic Data Handling (QC, GRM, LD, PCA) & Linear Mixed Models

v1.5.7
GPL-3
Authors
Hervé Perdry [cre, aut, cph], Claire Dandine-Roulland [aut, cph], Deepak Bandyopadhyay [cph] (C++ gzstream class), Lutz Kettner [cph] (C++ gzstream class)
Initial release
2020-09-18

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.