# Implementing non-parametric version of 2x2 Repeated Measures ANOVA in R

#### RobH

##### New Member
Hi, I have a 2x2 repeated measures design (i.e. 1 group of participants provide data for all 4 conditions in a fully factorial counterbalanced design [so there is no time factor to worry about]). The data is non-normal so I need to use a non-parametric equivalent of the 2x2 factorial ANOVA.

I've done some reading and it appears that there are a batch of different 'robust' methods, involving winsorized means/bootstrapping/rank-procedures that can apparently be used for such purposes. This seems fine but my problem is how to implement these methods.

I usually use SPSS for data analysis, but it does not provide a way of implementing these methods. From what I've read the R software appears to be the way to go. At my institution we have version 2.1.2. However I can't find a clear description of what code I should run to implement this analysis. I've got a copy of Wilcox 'Robust Estimation and Hypothesis Testing' but it's a bit over my head, and also appears to only talk about one-way repeated measures and then mixed designs, but misses out 2-way designs that are purely repeated measures. This is a problem I have found with a lot of the texts available for R, presumably because they are written with medical research in mind, where there is generally at least 1 between-subjects factor (i.e. treatment group vs control group).

Can anyone give me some straightforward advice as to how I can run a non-parametric 2x2 repeated measures analysis in R? Bear in mind that I have no real experience of R.

Thanks
RH

#### Tulip

##### New Member
Hi, I would like to revive this thread as I have the very same question.
That is, does anyone know how to run a non-parametric 2x2 repeated measures analysis in R?
Thanks, Vera

#### trinker

##### ggplot2orBust
Alright let's back the trolley up a minute so we can understand what the problem is (to quote one of my favorite scientists):

Einstien was asked what he would do if he had one hour to save the world he responded that he would spend fifty-five minutes defining the problem and only five minutes finding the solution.
Let's define the problem before we make a type 4 error: solving the wrong problem precisely

2. What is your DV(s) and type [ie. categorical (inlcude groups) or numeric (discrete, continuous, etc.)]?
3. What is your IV(s) and type [ie. categorical (inlcude groups) or numeric (discrete, continuous, etc.)]?

Once we have this information we can give better insight about how to approach it.

#### Tulip

##### New Member
Hi trinker,

I like the quote . Alright.

So I have a 2x2 within-subject design. Hence, each subject participated in four different conditions (2 factors with 2 levels).

My outcome variable is continuous, but not normally distribued (some conditions very skewed).

My hypothesis is that there will be an interaction between the two within-subject factors.

So far I have not been able to normalise the data using transformations (log, squareroot, etc). Therefore I would like to use a non-parametric analysis to test the interaction of the two factors.

Best,
Vera

#### trinker

##### ggplot2orBust
Why are you trying to normalize the data? What has told you that your data has to be normally distributed? The answer to this will depend on the advice given about parametric vs. nonparametric.

#### Tulip

##### New Member
I was trying to normalise the data in order to be able to use a normal parametric Repeated-Measures-ANOVA. Then it would be very easy to calculate an interaction between the two factors. In Friedman's ANOVA (the non-parametric equivalent to Repeated-Measures-ANOVA) I don't think I can specify factors (?!) and therefore I can only test for an overall effect but not the interaction between the factors.

>What has told you that your data has to be normally distributed?

I actually have the problem for two different dependent variables which I want to analyse separately (I did not say that above for simplicity.)

DV 1: It is numeric and continuous. Non-normality is only present in one of the four conditions as indicated by a significant Shapiro-Wilk test. The non-normality is due to ONE outlier participant who gave an unusually high response in this condition and this renders the distribution non-normal. Excluding this subject or the outlier-data-point seems wrong, as this would be in line with our hypothesis and would hence change the data in favor of our hypothesis.

DV 2: This second outcome variable is numeric and DISCRETE (ratings on a Likert-skale: from 1 to 7). Both Shapiro-Wilk and Kolmogorv-Smirnoff test are highly significant for this variable, indicating non-normality. That is because the scores are clustered at the low scores-end (1-2) rather than normally distributed across the whole range. Hence in the histograms I have a peak on the left side and then a long tail on the right.

#### Tulip

##### New Member
Oh sorry - you asked "What has told you that your data HAS TO BE normally distributed?" rather than "What has told you that your data was normally distributed?"

Well, I think the data have to be normally distributed if I want to run a normal parametric repeated-measures ANOVA on it, right? Since this is one assumption of the ANOVA.

#### trinker

##### ggplot2orBust
Linear models do not assume normality of the data but normality of the error terms (the residuals). You can run the repeated measures model (parametric) and determine normality of the residuals through a qqplot. This can be done by wrapping the model object with a call to plot as in: plot(mod1). If you see a departure from normality in the error terms then we'll worry about a non parametric test.

NOTE: The car package also has some nice diagnostic features for testing model assumptions (see the book R in Action, Robert Kabacoff, for a nice guide to using car for checking model assumptions)

#### Tulip

##### New Member
Oh really, just the residuals? I didnt know that. I have heard/read pretty often that the data themselves have to be normally distributed. Is that really wrong? Or does that only hold in some cases and in other cases you just need normality of the residuals?

Well, thank you for your answers so ! I will look into this further with the car package probably tomorrow, and then answer again.

#### victorxstc

##### Pirate
I think as I have learned hear, it is only the normality of the residuals, of course plus the sphericity (for this type of ANOVA).