change.cov.mat.representation: Takes variances and covarianves of effect estimates and puts...

Description Usage Arguments Details Value Author(s) Examples

Description

This function is used by corMeta.GLS.inverst.mats, the function that calculates the MetaGLS estimators for many SNPs at the same time. It puts variances and covariances of effect estimates from stratified analysis in a single matrix, in which each rows corresponds to a stacked covariance matrix of the estimated effects.

Usage

1

Arguments

var

a p by S matrix of variances of the estimated effects of each of p SNPs on a trait in each of S strata.

cov

a p by (S*(S-1)/2) matrix representing p vectors of covariances between the estimated effects of each of p SNPs on a trait in each of S strata.

Details

The given variances and covrariances are put in a single matrix, in which each row corresponds to the covariance matrix of the SNP effects of a single SNP across multiple strata. This function is used by corMeta.GLS.inverst.mats.

Value

An p by s^2 matrix in which each row represent a covariance matrix, as the concatanated rows of the matrix.

Author(s)

Tamar Sofer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
### create matrices of covariances and variances

n.strat <- 5
n.est <- 5
## create a positive definite matrix to be a covariance matrix
sigma <- matrix(rnorm(n.strat^2), n.strat, n.strat)
sigma <- t(sigma) 

vars <- matrix(rep(diag(sigma), n.est), nrow = n.est, ncol = n.strat, byrow = T)
colnames(vars) <- paste0("var.s", 1:n.strat)
covs <- matrix(rep(sigma[lower.tri(sigma)], n.est), nrow = n.est, byrow = T)
colnames(covs) <- c(paste0("cov.s1:", paste0("s", 2:n.strat)), paste0("cov.s2:", paste0("s", 3:n.strat)), paste0("cov.s3:", paste0("s", 4:n.strat)) , "cov.s4:s5")

### now change their representation:
change.cov.mat.representation(vars, covs)

tamartsi/MetaCor documentation built on May 31, 2019, 2:56 a.m.