inputcov: Input (Co)Variance Matrices

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

Description

This function inputs (co)variance matrices of a set of outcomes given the corresponding standard deviation and correlation values.

Usage

1

Arguments

sd

a m x k matrix of standard deviations for k outcomes in m matrices, or a vector for k outcomes in a single matrix.

cor

either a vector of length 1, m or k(k-1)/2, or alternatively a k x k or m x k(k-1)/2 matrix. See Details.

Details

Depending the number of outcomes k and matrices m, the argument cor is interpreted as:

Value

For a single matrix, the (co)variance matrix itself. For multiple matrices, a m x k(k+1)/2 matrix, where each row represents the vectorized entries of the lower triangle (with diagonal, taken by column) of the related (co)variance matrix (see vechMat).

Note

This function is imported from the package mixmeta. It is called internally by mvmeta for multivariate models to input the correlation(s) when only the within-unit variances are provided through the argument S. In this case, the correlation values are set through the argument Scor in the control list (see mvmeta.control).

Author(s)

Antonio Gasparrini <antonio.gasparrini@lshtm.ac.uk>

See Also

See xpndMat. See mvmeta.control.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# SOME RANDOM SD FOR A SINGLE MATRIX, WITH CONSTANT CORRELATION
(M <- inputcov(runif(4, 0.1, 3), 0.7))
# CHECK CORRELATION
cov2cor(M)

# NOW WITH A MORE COMPLEX CORRELATION STRUCTURE
(M <- inputcov(runif(3, 0.1, 3), c(0.7,0.2,0.4)))
cov2cor(M)

# MULTIPLE MATRICES
(V <- matrix(runif(5*3, 0.1, 3), 5, 3,
  dimnames=list(1:5, paste("V", 1:3, sep=""))))
inputcov(V, 0.6)

# WITH REAL DATA WHEN CORRELATIONS AVAILABLE
hyp
(S <- inputcov(hyp[c("sbp_se","dbp_se")], cor=hyp$rho))
# CHECK FIRST STUDY
cov2cor(xpndMat(S[1,]))

# USED INTERNALLY IN mvmeta
p53
inputcov(sqrt(p53[c("V1","V2")]), 0.5)
model <- mvmeta(cbind(y1,y2), S=cbind(V1,V2), data=p53, control=list(Scor=0.5))
model$S

mvmeta documentation built on Dec. 10, 2019, 5:07 p.m.