[R] cross-over designs

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Wed Oct 28 15:23:41 CET 2009

Data Analytics Corp. wrote:
> Hi,
> I have a dataset from a client where the data is from a cross-over
> design.  Basically, each subject in a survey was asked to rate two
> products, A and B.  The subject sampled A first and then after an
> appropriate wash-out period he/she sampled B.  The next subject did the
> same, but in a different order.  How can I do an ANOVA analysis on a
> cross-over design with only two treatments.  This is also a balanced design
> Thanks,
> Walt

The hard bit is often to knock data into the right format. Assuming that
you have a data in a data frame "mydata" in long format like this

ID product period score
1 A 1 2,3
1 B 2 3.4
10 B 1 5.6
10 A 2 7.8

then this should do the trick:


Alternatively, you can do it with t-tests comparing differences within
ID between the two product orderings. The test for main effect of
product can be obtained as a test of whether "1st - 2nd" depends on
whether A or B came first, and vice-versa for the main effect of period.
 The interaction test (carry-over, etc.) is obtained as a test of
whether the _sum_ of the two scores is order-dependent.

(Cynics may point out that it is usually no great loss just to do a
paired t-test, since period effects are usually weak and interactions
mostly undetectable in such designs.)

   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907

More information about the R-help mailing list