Generating a dataset satisfying / violating the RM-ANOVA sphericity assumption I was reading a research paper where they had a 2x3 repeated measures factorial design with a single DV. A suitable approach to this analysis would be a univariate repeated measures ANOVA. However, its possible that sphericity is violated (and a GG/HF adjustment required). They chose to use a MANOVA instead.
I'm writing a term paper on how F test results/interpretations could differ between a sphericity violated case (both with and without adjustment) and a non-violated case, between the univariate and multivariate approaches.
I want to base my paper on the paper that I read (same design), but I dont have access to the original dataset (lets assume for this question that I'm unable to get it from the authors). How do I generate a dataset, of the same design as outlined above, where I can guarantee that sphericity will be violated? And likewise, a dataset where sphericity is guaranteed to not be violated?
I'd be happy to generate this using R, MATLAB, or Python
The expected layout should be something like this:

I'd like a way to control the means of these sub groups so I can manually make sure that factorx_1 and factorx_2 are significantly different for example
 A: You say you have two whole plot factor levels and three sub plot factor levels (the repetitions). 
Sphericity means that the covariance matrix of the effect estimators has equal positive eigenvalues. (As you know, the set $\{x|x'Ax = r\}$ is a sphere iff $A$ has equal positive eigenvalues. That's where the name comes from.) Then this eigenvalue is the only nuisance parameter, you'll automatically get rid of it by cancellation in the usual univariate ANOVA-$F$-statistic.
Assuming $\hat{\mu}$ to be the three-dimensional mean vector, the effect estimator is $H \hat{\mu}$, where $H$ is a hypothesis matrix centering matrix $C_3 = [\delta_{ij}-\frac{1}{3}]_{ij}$). Let $\Sigma$ be the 6x6-covariance matrix in both groups. Then you'll have sphericity iff $H\Sigma H'$ is spherical. Popular spherical choices are e.g. due to $\Sigma =I_6$ with hypotheses $H=I_6$ (would test if all measurements are 0, not interesting) or $H=P_2 \otimes P_3$ (would test the interaction of both factors) or $H=I_2 \otimes P_3$ (would test the effect only of the factor which has 3 levels) or due to a compound symmetry covariance matrix, that is in R-code
Sigma <- sigmavar*diag(6) + sigmacov

sigmacov and sigmavar are arbitrary positive real values. You can think of sigmacov as the variance of the (random) subject effect and sigmavar as the variance of all the n*d error terms. In fact, that's the rationale of the classical spherical ANOVA model from the textbooks.
Just check by 
eigen(H %*% Sigma %*% t(H))$values

that the eigenvalues are in fact positive or (numerically close to) zero. Maybe there are even more possible spherical constellations with (somehow) meaningful hypotheses matrices; I don't know.  
Popular nonspherical constellations are e.g. if you take autoregressive covariance matrices:
for (i in 1:6){for (j in 1:6) {Sigma[i,j] <- 0.2**abs(i-j)}} #0<rho<1

You will not have any problem in finding more of them. 
Ahe random data set for one sample can be generated by 
L <- chol(Sigma)
Y1 <- matrix(rnorm(n*6),n,6) %*% t(L) + rep(1,n) %*% t(mu)

The noncentrality parameter will be sum((H %*% mu)**2). Note that the covariance matrix doesn't appear there. That's a difference to the MANOVA-approach. 
