[R] format of summary.lm for 2-way ANOVA

Chuck Cleland ccleland at optonline.net
Sat Mar 3 11:53:56 CET 2007


Patrick Drechsler wrote:
>  Hi,
> 
> I am performing a two-way ANOVA (2 factors with 4 and 5 levels,
> respectively). If I'm interpreting the output of summary correctly,
> then the interaction between both factors is significant:
> 
> ,----
> | ## Two-way ANOVA with possible interaction:
> | > model1 <- aov(log(y) ~ xForce*xVel, data=mydataset)
> |
> | > summary(model1)
> |              Df  Sum Sq Mean Sq F value    Pr(>F)    
> | xForce        3  16.640   5.547 19.0191 1.708e-11 ***
> | xVel          4  96.391  24.098 82.6312 < 2.2e-16 ***
> | xForce:xVel  12  10.037   0.836  2.8681 0.0008528 ***
> | Residuals   371 108.194   0.292                      
> | ---
> | Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
> | 3 observations deleted due to missingness
> `----
> 
> To see the interactions in detail I call summary.lm:
> 
> ,----
> | > summary.lm(model1)
> | 
> | Call:
> | aov(formula = log(y) ~ xForce * xVel, data = mydataset)
> | 
> | Residuals:
> |      Min       1Q   Median       3Q      Max 
> | -2.04830 -0.32420 -0.04653  0.34928  1.46755 
> | 
> | Coefficients:
> |                  Estimate Std. Error t value Pr(>|t|)    
> | (Intercept)     -1.663406   0.027335 -60.853  < 2e-16 ***
> | xForce.L         0.408977   0.054726   7.473 5.68e-13 ***
> | xForce.Q         0.101240   0.054670   1.852   0.0648 .  
> | xForce.C        -0.068068   0.054613  -1.246   0.2134    
> | xVel.L           1.079042   0.061859  17.444  < 2e-16 ***
> | xVel.Q           0.339802   0.061439   5.531 6.03e-08 ***
> | xVel.C           0.015422   0.060751   0.254   0.7997    
> | xVel^4          -0.044399   0.060430  -0.735   0.4630    
> | xForce.L:xVel.L  0.622060   0.123966   5.018 8.12e-07 ***
> | xForce.Q:xVel.L  0.034298   0.123718   0.277   0.7818    
> | xForce.C:xVel.L -0.114776   0.123470  -0.930   0.3532    
> | xForce.L:xVel.Q  0.309293   0.123057   2.513   0.0124 *  
> | xForce.Q:xVel.Q  0.054798   0.122879   0.446   0.6559    
> | xForce.C:xVel.Q -0.144219   0.122700  -1.175   0.2406    
> | xForce.L:xVel.C  0.110588   0.121565   0.910   0.3636    
> | xForce.Q:xVel.C -0.001929   0.121502  -0.016   0.9873    
> | xForce.C:xVel.C -0.039477   0.121438  -0.325   0.7453    
> | xForce.L:xVel^4  0.090491   0.120870   0.749   0.4545    
> | xForce.Q:xVel^4 -0.002762   0.120861  -0.023   0.9818    
> | xForce.C:xVel^4 -0.028836   0.120852  -0.239   0.8115    
> | ---
> | Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
> | 
> | Residual standard error: 0.54 on 371 degrees of freedom
> |   (3 observations deleted due to missingness)
> | Multiple R-Squared: 0.5322,	Adjusted R-squared: 0.5082 
> | F-statistic: 22.21 on 19 and 371 DF,  p-value: < 2.2e-16 
> `----
> 
> I am wondering what the logic is behind the formatting of
> rownames. What do the strings "L", "Q", "C" and "^4" mean?

  The default contrast for ordered factors is contr.poly(), and "L",
"Q", "C" and "^4" refer to linear, quadratic, cubic, and quartic,
respectively.
  You might look at some plots if you have not already.  For example:

with(mydataset, interaction.plot(xForce, xVel, log(y)))

library(lattice)
bwplot(log(y) ~ xForce | xVel, data = mydataset)

> Apologies in case I missed something obvious in the relevant
> documentations/archives.
> 
> Thanks for any pointers,
> 
> Patrick
> 
> PS: Here are some details about the dataset:
> 
> ,----
> | > summary(mydataset)
> |        y            xForce     xVel   
> |  Min.   :0.03662   0.01:97   10  :79  
> |  1st Qu.:0.10376   0.1 :98   50  :80  
> |  Median :0.16314   1   :98   100 :80  
> |  Mean   :0.26592   2   :98   500 :80  
> |  3rd Qu.:0.28077   NA's: 3   5000:72  
> |  Max.   :2.39490             NA's: 3  
> |  NA's   :3.00000
> | 
> | > str(mydataset)
> | 'data.frame':	394 obs. of  3 variables:
> |  $ y     : num  0.167 0.158 0.152 0.158 0.131 ...
> |  $ xForce: Ord.factor w/ 4 levels "0.01"<"0.1"<"1"<..: 1 2 3 4 1 2 3 4 1 2 ...
> |  $ xVel  : Ord.factor w/ 5 levels "10"<"50"<"100"<..: 3 3 3 3 1 1 1 1 2 2 ...
> `----
> 
> I am using
> 
> platform       i486-pc-linux-gnu           
> arch           i486                        
> os             linux-gnu                   
> system         i486, linux-gnu             
> status                                     
> major          2                           
> minor          4.1                         
> year           2006                        
> month          12                          
> day            18                          
> svn rev        40228                       
> language       R                           
> version.string R version 2.4.1 (2006-12-18)
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894



More information about the R-help mailing list