# Tests of within subjects contrasts in R

I have run a split splot model in SPSS (via repeated measures function) and I would like to reproduce my results using R. To do so I used ezANOVA function from ez package to obtain sphericity tests and correction and type III SS. I have read that aov function does not give type III SS. So far the results are identical with those from SPSS but I cannot tell so when I run tests of within subjects contrasts. I use polynomial contrasts and my factor has six levels. What I manage to get is t-values instead of f-values or f-values but not the same as in SPSS. Here is my data and code id subj treat m1 m2 m3 m4 m5 m6 1 1 1 455 460 510 504 436 466 2 2 1 467 565 610 596 542 587 3 3 1 445 530 580 597 582 619 4 4 1 485 542 594 583 611 612 5 5 1 480 500 550 528 562 576 6 6 2 514 560 565 524 552 597 7 7 2 440 480 536 484 567 569 8 8 2 495 570 569 585 576 677 9 9 2 520 590 610 637 671 702 10 10 2 503 555 591 605 649 675 11 11 3 496 560 622 622 632 670 12 12 3 498 540 589 557 568 609 13 13 3 478 510 568 555 576 605 14 14 3 545 565 580 601 633 649 15 15 3 472 498 540 524 532 583

m1-m6 represent measurements in 6 different time points. My code for the contrasts.

long.df<- melt(data, id=c('subj','treat')) long.df<- long.df[order(long.df\$subj)] names(long.df)<- c('subj','treat','time','meas') mod<- lm(meas~time + time^2 + time^3 + time^4 + time^5, long.df) summary(mod) # this is how I obtain t-values for the polynomial contrasts # mod1<- aov(meas~time + time^2 + time^3 + time^4 + time^5, long.df) summary(mod1, split=list(time=list("Linear"=1, "Quad"=2,'q'=3,'f'=4,'fif'=5))) # this is how i obtain f-values #

I think that the F-values correspond to type 1 SS (as I use aov function). How am I wrong? Is there a way to conduct the Tests of within subjects contrasts and obtain type III SS so I will have identical results to SPSS? Here are the SPSS results. Many thanks in advance!

Source time Type III SS/ df/ Mean Square/ F/ Sig.
time Linear 123662.881/ 1/ 123662.881/ 83.591/ .000
Quadratic 5928.007/ 1/ 5928.007/ 18.968/ .001
Cubic 10462.676/ 1/ 10462.676/ 28.075/ .000
Order 4 798.193 / 1/ 798.193/ 4.010/ .068
Order 5 1702.743/ 1/ 1702.743/ 4.878/ .047

aov does use type 1 SS.

You could do something like this (in the car package) instead: print(Anova(lm(Score~1+A+B+C+A:B+B:C+A:C+A:B:C, data=dat), type="III"))

You can change type to "I" or "II" to get the various types of SS.