test2levelInteraction: Test SNPxstrata interaction when there are only two strata

Description Usage Arguments Details Value Note Author(s) Examples

Description

Estimate and test the difference in SNP effect the trait between two strata.

Usage

1

Arguments

beta

a p by s matrix of estimated effects of each of p SNPs on the trait in each of 2 strata.

var

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

cov

a p by 1 matrix of a vector of length p of covairances between the estimated effects of each of p SNPs on the trait in each of 2 strata.

Details

For each SNP, estimates the difference in SNP effect between strata, and tests the null hypothesis that this effect is zero.

Value

A matrix with column corresponding to beta = the estimated effect difference (equivalently, the interaction effect), var = the variance of the estimated beta, test.stat = the test.statistics and pval = the p-value of the test.

Note

This function is used by stratLMMTest when two strata are analyzed.

Author(s)

Tamar Sofer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
### create a small data set with the right formating:
require(mvtnorm)
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) 

effects <- rmvnorm(n.est, c(2,2,3,3,0), sigma)
colnames(effects) <- paste0("Beta.s", 1:n.strat)
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[upper.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")

## this will give an error:
# test2levelInteraction(effects, vars, covs)
### error! there are more than 2 strata

test2levelInteraction(effects[,1:2], vars[,1:2], covs[,1])

test2levelInteraction(effects[,4:5], vars[,4:5], covs[,grep("cov.s4:s5", colnames(covs))])

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