[R] Probability for ANOVA

Liaw, Andy andy_liaw at merck.com
Tue Jan 27 15:55:27 CET 2004


One way is:

> dat = read.table("clipboard", head=T, row=1)
> dat
        Treat1 Treat2 Treat3 Treat4
Animal1     36     37     35     39
Animal2     33     34     36     37
Animal3     37     35     33     38
Animal4     34     36     34     35
Animal5     35     36     33     36
> y <- unlist(dat)
> y
Treat11 Treat12 Treat13 Treat14 Treat15 Treat21 Treat22 Treat23 Treat24
Treat25 
     36      33      37      34      35      37      34      35      36
36 
Treat31 Treat32 Treat33 Treat34 Treat35 Treat41 Treat42 Treat43 Treat44
Treat45 
     35      36      33      34      33      39      37      38      35
36 
> trt = gl(4,5)
> trt
 [1] 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4
Levels: 1 2 3 4
> summary(aov(y~trt))
            Df Sum Sq Mean Sq F value  Pr(>F)  
trt          3 20.950   6.983  3.4917 0.04033 *
Residuals   16 32.000   2.000                  
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 

If you just want the p-value, given the ANOVA table, then you can do:

> pf(3.492, 3, 16, lower.tail=FALSE)
[1] 0.04032243



Andy
 

> From: Laurent Houdusse
> 
> Hi all!
> 
> I have  4 treatments on 5 animals
>            Treat1   Treat2    Treat3    Treat4
> Animal1      36       37        35       39
> Animal2      33       34        36       37
> Animal3      37       35        33       38
> Animal4      34       36        34       35
> Animal5      35       36        33       36
> 
> I use an Anova and i try to verify calcul
> So i retrieve:
>                     DF      SS       MS      F       P
> Between Groups       3    20.950   6.983   3.492
> Residual            16    32.000   2.000
> Total               19    52.950   2.787
> 
> How can i calcul the p-Value? Is there a function to do this?
> 
> 
> Laurent Houdusse 
> Analyste Programmeur
> 


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}




More information about the R-help mailing list