search for: inv_cov_rank

Displaying 1 result from an estimated 1 matches for "inv_cov_rank".

2012 Feb 17
2
(subscript) logical subscript too long in using apply
...med_ge[m_i,m_j]=1 } y=c(1,1,1,1,1,1,0,0,0,0) n<-c(sum(y == 1),sum(y==0)) touse3 <- y==1 T1<- apply(med_ge[touse3,], 2, mean) T0<- apply(med_ge[!touse3,], 2, mean) T=rbind(T1,T0) Tbar=colMeans(T) Tdiff=T-Tbar cov_rank=cov(med_ge) inv_cov_rank=ginv(cov_rank) LN=0 for(m_i in 1:length(n)) { LN <- LN+((Tdiff[m_i,]%*%inv_cov_rank)%*%t(Tdiff)[,m_i])*n[m_i] } return(LN) }} func_LN(data) Now, I want to try this function on subgroups of data. So I used "apply" result <- apply(gs , 1 , function(z) fun...