Question

How to create a covariance matrix by eigen-values, so that mauchly's test indicates to reject the null hypothesis. Is there a pattern of a covariance-matrix for a experimental design which produces r.v., so that the assumption of sphericity has been violated? If I calculated a arbitrary covariance-matrix by given eigen-values, and for that matrix I produce an experiment by the following source-code, then mauchlys test rejects the null hypothesis sometimes. How to simulate normally distributed data which violates the assumption of sphericity?

require(corpcor)
require(reshape2)
require(mvtnorm)

getCovariance<-function(lambda){
   j<-1
   Sigma<--1
   while(any(Sigma<=0)){    
      set.seed(j)
  X<-matrix(rnorm(50*length(lambda)),50,length(lambda))  
  R<-cor(X)           
  P<-eigen(R)$vector 
  Sigma<-t(P)%*%diag(lambda)%*%P   
      j<-j+1
   }             
   Sigma
 }

 subject<-50
 treatment<-4
 set.seed(1)
 lambda<-sample(1:subject,treatment)
 cov<-getCovariance(lambda)
 exp<-rmvnorm(mean=rep(0,treatment),sigma=cov,n=subject,method="chol")
 fit<-lm(exp~1)
 mauchly.test(fit,X=~1)

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top