0
$\begingroup$

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

$\endgroup$

1 Answer 1

1
$\begingroup$

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.

For more information about how types of SS work see this link http://mcfromnz.wordpress.com/2011/03/02/anova-type-iiiiii-ss-explained/

Hope this helps!

$\endgroup$
5
  • $\begingroup$ @ Sarah Thomas. Your comment along with the link was very helpful. But, I am still can't understand how am I wrong. You see SPSS uses F-tests in within subjects contrasts tests, especially type III ones. What I am trying to do is reproduce those results using R but I can't figure out how. The code I tried and I mentioned above gives different results from SPSS showing that I am wrong in some way. $\endgroup$
    – Manos
    May 5, 2014 at 10:30
  • $\begingroup$ @Manos I'm a bit confused about what you tried. Did you try print(Anova(lm(meas~time + time^2 + time^3 + time^4 + time^5, long.df), type="III"))? $\endgroup$ May 13, 2014 at 21:55
  • $\begingroup$ @ Sarah Thomas. Yes I tried it but I cannot get F tests for every degree of the polynomial separately. I only get the F-test for the whole time effect. My professor told me that I must use lme function (lme4 package) , which I did but I have not managed to get the desired results so far. I am still working on it, if I have sth I will let you know. $\endgroup$
    – Manos
    May 15, 2014 at 8:26
  • $\begingroup$ @Manos That's strange, when I run print(Anova(lm(meas~time + time^2 + time^3 + time^4 + time^5, long.df), type="III")) on some data I made up I get an F for each term in the model. Are you sure you used the print function? $\endgroup$ May 15, 2014 at 14:49
  • $\begingroup$ @ Sarah Thomas. The truth is that I did not use print function.Thanks for pointing it out. However, my professor told me that lme function should be used here. I will try with print and I will let you know. $\endgroup$
    – Manos
    May 16, 2014 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.