[R] is this an ANOVA ?

Steven McKinney smckinney at bccrc.ca
Wed Apr 13 04:54:31 CEST 2011


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Ubuntu Diego
> Sent: April-12-11 5:10 PM
> To: r-help at r-project.org
> Subject: [R] is this an ANOVA ?
> 
> Hi all,
> 	I have a very easy questions (I hope). I had measure a property of plants, growing in three
> different substrates (A, B and C). The rest of the conditions remained constant. There was very high
> variation on the results.
> 	I want to do address, whether there is any difference in the response (my measurement) from
> substrate to substrate?
> 
> x<-c('A','A','A','A','A','B','B','B','B','B','C','C','C','C','C') # Substrate type
> y <- c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) # Results of the measurement
> MD<-data.frame(x,y)
> 
> 	I wrote a linear model for this:
> 
> summary(lm(y~x,data=MD))
> 
> 	This is the output:
> 
> Call:
> lm(formula = y ~ x, data = MD)
> 
> Residuals:
>        Min         1Q     Median         3Q        Max
> -2.000e+00 -1.000e+00  5.551e-17  1.000e+00  2.000e+00
> 
> Coefficients:
>             Estimate Std. Error t value Pr(>|t|)
> (Intercept)   3.0000     0.7071   4.243 0.001142 **
> xB            5.0000     1.0000   5.000 0.000309 ***
> xC           10.0000     1.0000  10.000 3.58e-07 ***
> ---
> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> 
> Residual standard error: 1.581 on 12 degrees of freedom
> Multiple R-squared: 0.8929,	Adjusted R-squared: 0.875
> F-statistic:    50 on 2 and 12 DF,  p-value: 1.513e-06
> 
> 	I conclude that there is an effect of substrate type (x).
> 	NOW the questions :
> 		1) Do the fact that the all p-values are significant means that all the groups are
> different from each other ?

No, the small p-values indicate that the associated estimate appears to be significantly different from zero.

You can use the package "multcomp" to do multiple comparisons.

     > require("multcomp")
     > lma <- aov(y ~ x, data = MD)
     > lmamc <- glht(lma, linfct = mcp(x = "Tukey"))
     > ci.lma <- confint(lmamc)
     > ci.lma

              Simultaneous Confidence Intervals

     Multiple Comparisons of Means: Tukey Contrasts
     
     
     Fit: aov(formula = y ~ x, data = MD)

     Quantile = 2.667
     95% family-wise confidence level
 

     Linear Hypotheses:
                Estimate lwr     upr    
     B - A == 0  5.0000   2.3330  7.6670
     C - A == 0 10.0000   7.3330 12.6670
     C - B == 0  5.0000   2.3330  7.6670

     > lmacld <- cld(lmamc)
     > plot(lmacld)
     > plot(ci.lma)
     



> 		2) Is there a (easy) way to plot,  mean plus/minus 2*sd for each substrate type ? (with
> asterisks denoting significant differences ?)

Not that I know of, though the multcomp tables and plots yield logically equivalent results and plots.
Writing a few lines of code to accomplish your graph is fairly straightforward.

HTH

Steven McKinney


> 
> 
> 	THANKS !
> 
> version
> platform       x86_64-apple-darwin9.8.0
> arch           x86_64
> os             darwin9.8.0
> system         x86_64, darwin9.8.0
> status
> major          2
> minor          11.1
> year           2010
> month          05
> day            31
> svn rev        52157
> language       R
> version.string R version 2.11.1 (2010-05-31)
> 
> ______________________________________________
> R-help at r-project.org 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.



More information about the R-help mailing list