[R] newbie question on contrasts and aov
Wolfgang Pauli
wolfgangpauli at web.de
Sun Jan 11 17:27:32 CET 2004
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
...
More information about the R-help
mailing list