# Simulating data for repeated measures ANOVA

I am currently working on a simulation study in which I compare two methods for analysing data from a repeated measures design. Let's say there are n subjects, and each subject goes through i conditions of the experiment. In each condition, there are j trials. So for each subject, I have i*j values. Since the data I want to simulate comes from an response time experiment, it is not normally distributed but positively skewed. An often used distribution to simulate reaction times is the ExGaussian with its three parameters mu, sigma and tau.

Well, because I am conducting a simulation study, I wanna have control over all variables of interest (e.g sample size, number of treatments, number of observations per treatment etc.). Additionally, I want to be able to control the assumption of sphericity. And that's the problem. I figured out to ways for simulating the data. Using the first, I'm able to manipulate everything but sphericity. In the second approach, I can manipulate sphericity but lose control for some other variables. My two approaches are as following:

1. Sample the data for every subject
Sample the data for every subject in each treatment condition from the ExGaussian. To get a Treatment-Effect, I change one parameter of the ExGaussians such as mu. Moreover, I can incorporate a subject effect by varying one parameter such as mu. And of course, the number of values I sample determines the number of observations per subject per treatment.

2. Sample the data for every treatment condition
To be able to manipulate sphericity, I have to get access to the correlation of the different treatment conditions. Put simply, sphericity is the assumption that the correlation between treatments has to be the same for all pairs. I figured out a way to get correlated non-normally distributed data for which I can monitor the correlation. But, and that's the problem, I am sampling the data for every treatment condition, not as described in method 1, for each subject.

Taking method 1, I don't have control over sphericity.

Taking method 2, I lose control for the subject effect and number of observations per subject because I'm sampling each treatment condition.

Is there any way in which I could integrate both aspects?

• I am not sure if he covers this, but a good book on simulation is Simulating data with SAS by Rick Wicklin (he deals with SAS but the methods should be exportable). Again, the book is at the office and I am home, but you can take a look at the TOC and see if it will help. – Peter Flom Mar 17 '14 at 10:13
• thanks, looks promising (even though I use R), but unfortunately I don't have access to it. – beginneR Mar 17 '14 at 10:30