LDcov: Calculate longitudinal distance covariance statistics.

Description Usage Arguments Value Examples

View source: R/LDcov.R

Description

Calculate longitudinal distance covariance statistics.

Usage

1
LDcov(x.dist = NULL, y.dist = NULL, nums = NULL, bmat = NULL)

Arguments

x.dist

A block-diagonal distance matrix of each block being pairwise distance matrix of genes for each subject.

y.dist

A block-diagonal distance matrix of each block being pairwise distance matrix of clinical outcomes for each subject.

nums

A vector of integer numbers indicating the number of repeated measures for each subject.

bmat

A numerical matrix with one column for each subject (binary values indicating the locations of the repeated measures for that subject).

Value

returns the longitudinal distance covariance statistics.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: require(Matrix)
x <- cbind(rnorm(7),rnorm(7)) ## two genes
y <- cbind(rnorm(7),rnorm(7)) ## two clinical outcomes
## Two subjects: the first one has three measures
## while the other one has four measures
ID <- c(1,1,1,2,2,2,2) ## The IDs for the two subjects.
nums <- c(3,4) ## number of repeated measures for each subjects
## prepare block-diagonal distance matrix for genes and clinical outcomes
lmat <- lapply(nums,function(x){z=matrix(1,nrow=x,ncol=x)})
mat <- as.matrix(bdiag(lmat))
lmat <- lapply(nums,function(x){z=matrix(0,nrow=x,ncol=x);z[,1]=1;z})
bmat <- as.matrix(bdiag(lmat))
ind <- apply(bmat,2,sum)
bmat <- bmat[,ind!=0]
ydist <- as.matrix(dist(y))*mat
xdist <- as.matrix(dist(x))*mat
LDcov(x.dist=xdist,y.dist=ydist,nums=nums,bmat)

Example output

Loading required package: Matrix
[1] 1.573121

dcGSA documentation built on Nov. 8, 2020, 7:53 p.m.