[R] Linear and cuadratic effects

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Nov 24 08:27:23 CET 2005


1) You need to declare ordered factors for your terms:

A <- ordered(A)
B <- ordered(B)

2) You want summary() not anova():

> summary(aov(y~(A*B)))
             Df  Sum Sq Mean Sq  F value    Pr(>F)
A            2 15.9433  7.9717 170.8214 6.953e-08
B            2  3.1633  1.5817  33.8929 6.461e-05
A:B          4  0.6933  0.1733   3.7143    0.0473
Residuals    9  0.4200  0.0467

and (if I understand you correctly) to use its optional argument 'split'

summary(aov(y~(A*B)), split = list(A = list(L = 1, Q = 2),
                                    B = list(L = 1, Q = 2)))

(L for 'linear', Q for 'quadratic')

or possibly with 'expand.split = FALSE'. See ?summary.aov.


On Wed, 23 Nov 2005, Alma Cristina Núñez del Toro wrote:

>
>   I'd  like  to know how to obtain a table of anova of a 3^2 desing with
>   linear  and  cuadratic  sum  of  squares  because if I use "aov", this
>   comand only bring me the linear sum of squares:
>
>   > A<-rep(c(rep(-1,3),rep(0,3),rep(1,3)),2)
>   > B<-rep(rep(c(-1,0,1),3),2)
>   >
>   y<-c(1.5,1.4,0.8,3.5,2.9,1.8,4,3.8,2.7,1.2,1.3,1.2,3.2,2.5,2,4.2,3.4,3
>   )
>   > anova(aov(y~(A*B)))
>
>
>   Analysis of Variance Table
>   Response: y
>                 Df  Sum Sq Mean Sq  F value    Pr(>F)
>   A             1 15.6408 15.6408 204.0109  9.711e-10 ***
>   B             1   3.1008  3.1008   40.4457   1.769e-05 ***
>   A:B          1   0.4050  0.4050     5.2826      0.03746 *
>   Residuals 14  1.0733  0.0767
>   ---
>   Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

-- 
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


More information about the R-help mailing list