newbie question on contrasts and aov
Notice `SPKType III Sum of Squares'. I don't believe your contrasts are orthogonal, and R's are sequential sum of squares. Also, are you sure these are the same contrasts? I presume this is contr.sdif from MASS (in which case it is churlish not to credit it), and SPSS's contrasts look more like Helmert contrasts from their labelling. Since it appears all your treatments are within subjects you do seem to be making life difficult for yourself. Although I would have done a simple fixed-effects analysis, applying summary.lm to the bottom stratum would give you simple t-tests for each contrast, including actual estimates of the magnitudes.
On Sun, 11 Jan 2004, Wolfgang Pauli wrote:
I try to move from SPSS to R/S and am trying to reproduce the results of SPSS
in R. I calculated a one-way anova with "spk" as experimental factor and erp
as depended variable.
The result of the Anova are the same concearning the mean square, F and p
values. But I also wanted to caculate the contr.sdif(4) contrast on spk. The
results are completely different now. I hope anybody can help me.
Thanks, Wolfgang
This is what I get in SPSS:
Tests of Within-Subjects Contrasts
Measure: MEASURE_1
Source SPKType III Sum of Squares df Mean Square F Sig.
SPK Level 2 vs. Level 1 3,493 1 3,493 2,026 ,178
Level 3 vs. Previous 20,358 1 20,358 10,168 ,007
Level 4 vs. Previous 18,808 1 18,808 15,368 ,002
Error(SPK) Level 2 vs. Level 1 22,414 13 1,724
Level 3 vs. Previous 26,030 13 2,002
Level 4 vs. Previous 15,911 13 1,224
This is the result in R:
Error: sub
Df Sum Sq Mean Sq F value Pr(>F)
Residuals 13 205.79 15.83
Error: Within
Df Sum Sq Mean Sq F value Pr(>F)
spk 3 29.425 9.808 9.4467 8.055e-05 ***
spk: p 1 1.747 1.747 1.6821 0.2022649
spk: q 1 13.572 13.572 13.0719 0.0008479 ***
spk: r 1 14.106 14.106 13.5861 0.0006915 ***
Residuals 39 40.493 1.038
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
Spk.df <- data.frame(sub,spk,erp)
subset(Spk.df, subset=(sub!="14oddball" & sub!="18odd" & sub!="19odd" &
sub!="20oddball")) -> Spk.selected.df
contrasts(Spk.selected.df$spk) <- contr.sdif(4)
aov(erp ~ spk + Error(sub), data=Spk.selected.df) -> Spk.aov
summary(Spk.aov,data=Spk.selected.df,split=list(spk=list(p=1,q=2,r=3)))
this is the the beginning of the dataframe, which I use:
sub spk erp
1 10oddball spk1 2.587
2 11oddball spk1 -0.335
3 12oddball spk1 5.564
5 15oddball spk1 0.691
6 17oddball spk1 -1.846
10 21oddball spk1 1.825
11 22oddball spk1 0.370
12 2oddball spk1 3.234
13 3oddball spk1 1.462
14 5oddball spk1 2.535
15 6oddball spk1 9.373
16 7oddball spk1 2.132
17 8oddball spk1 -0.518
18 9oddball spk1 2.450
19 10oddball spk2 2.909
20 11oddball spk2 0.708
21 12oddball spk2 4.684
23 15oddball spk2 3.599
...
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595