covmat: construct variance-covariance matrix

Description Usage Arguments Details Value Note Author(s) Examples

View source: R/cpcbp.R

Description

Generates a variance-covariance matrix from variances and correlations

Usage

1
covmat(vars, cors, tol=1e-7)

Arguments

vars

a numeric vector of variances

cors

a numeric vector of correlations: replicated to the appropriate length if necessary

tol

numeric tolerance for checking positive definiteness

Details

Creates a variance-covariance matrix with the specified variances and correlations.

Value

A square numeric matrix.

Note

Warns, but does not stop, if the matrix is non-positive-definite.

Author(s)

Ben Bolker

Examples

1
  covmat(c(1,2,3),c(0.4,-0.2,-0.1))

bbolker/cpcbp documentation built on May 10, 2017, 10:26 p.m.