Description Usage Arguments Value Examples
Calculate longitudinal distance covariance statistics.
1 |
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). |
returns the longitudinal distance covariance statistics.
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)
|
Loading required package: Matrix
[1] 1.573121
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.