parseCovMatrix: Parse a covariance matrix

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/parseCovMatrix.R

Description

Creates a symmetric positive definite matrix from a vector if possible, or checks if a given matrix is symmetric positive definite.

Usage

1
  parseCovMatrix(values, nCov, tol = 1e-06)

Arguments

values

(Required) Either a matrix or a mixed character-numeric vector

nCov

(Required) The number of rows and columns that should be available in the resulting matrix

tol

(Optional) Numerical tolerance for the positive-definiteness check. By default, the tolerance is used as 1e-06

Details

parseCovMatrix attempts to create a symmetric positive definite matrix of dimension nCov x nCov. If values is a matrix, parseCovMatrix will simply check that it is symmetric and positive definite up to a tolerance as inidicated by tol. If it is a numeric vector, parseCovMatrix will try to create an nCov x nCov positive definite symmetric matrix, with the method of creation depending on values and nCov. If values contains a single entry, an nCov x nCov diagonal matrix with that single value repeated nCov times will be created. If the number of entries in "values" is equal to "nCov", parseCovMatrix will create a diagonal matrix whose diagonal will be equal to "values". if the number of entries in "values" is equal to nCov * (nCov+1) / 2, parseCovMatrix will create a positive definite symmetric matrix with the entries for the lower triangle taken from "values". If none of these conditions hold or if the entries of "values" are not compatible with positive definite symmetric matrices, an error will be printed.

Value

A positive definite symmetric matrix

Author(s)

Mike K Smith mstoolkit@googlemail.com

See Also

checkSymmetricPDMatrix

Examples

1
2
3
  parseCovMatrix(2, nCov = 3)
  parseCovMatrix(c(1,2,3), nCov = 3)
  parseCovMatrix(c(1,2,4), nCov = 2)

MSToolkit documentation built on May 2, 2019, 6:30 p.m.