lindep <-
function(x,con,cmat,alpha=.05,tr=.2){
#
# Compute a test statistic based on the
# linear contrast coefficients in con and the covariance matrix
# cmat.
#
# The data are assumed to be stored in x in list mode
# or a matrix with columns correpsonding to groups.
#
# con is a J by d matrix containing the contrast coefficients that are used.
# d=number of linear contrasts
#
#
if(is.matrix(x))x<-listm(x)
if(!is.list(x))stop("Data must be stored in a matrix or in list mode.")
con<-as.matrix(con)
J<-length(x)
w<-vector("numeric",J)
xbar<-vector("numeric",J)
for(j in 1:J){
xbar[j]<-mean(x[[j]],tr=tr)
}
ncon<-ncol(con)
psihat<-matrix(0,ncol(con),4)
dimnames(psihat)<-list(NULL,c("con.num","psihat","se","test"))
w<-cmat
for (d in 1:ncol(con)){
psihat[d,1]<-d
psihat[d,2]<-sum(con[,d]*xbar)
cvec<-as.matrix(con[,d])
sejk<-sqrt(t(cvec)%*%w%*%cvec)
psihat[d,3]<-sejk
psihat[d,4]<-psihat[d,2]/sejk
}
list(test.stat=psihat)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.