Estatística II - Exemplos

`"

Capítulo 7

Exemplo 7.1

Análise de variância.
> morango <- read.table("morango.txt", header = T, dec = ",")
> morango
 
   trat   resp
1     A 0.1958
2     A 0.1301
3     A 0.1806
4     A 0.1545
5     A 0.1252
6     A 0.1882
7     A 0.2211
8     A 0.1734
9     G 0.3627
10    G 0.4841
11    G 0.4119
12    G 0.4457
13    G 0.4755
14    G 0.5174
15    G 0.4173
16    G 0.4001
17    L 0.1621
18    L 0.1150
19    L 0.2011
20    L 0.2123
21    L 0.1475
22    L 0.1922
23    L 0.1802
24    L 0.2248
25    C 0.2841
26    C 0.3099
27    C 0.2922
28    C 0.1505
29    C 0.2345
30    C 0.1652
31    C 0.1379
32    C 0.1960
 
> morango.av <- aov(resp ~ trat, data = morango)
> summary(morango.av)
 
            Df  Sum Sq Mean Sq F value    Pr(>F)    
trat         3 0.38280 0.12760  52.811 1.194e-11 ***
Residuals   28 0.06765 0.00242                      
---
Signif. codes:  0 `***´ 0.001 `**´ 0.01 `*´ 0.05 `.´ 0.1 ` ´ 1 
 
Teste de comparação de médias
As médias podem ser obtidas da seguinte maneira:
> tapply(morango$resp, morango$trat, mean)
 
        A         C         G         L 
0.1711125 0.2212875 0.4393375 0.1794000 
 
O teste de Tukey é realizado da seguinte forma:
> morango.tu <- TukeyHSD(morango.av)
> morango.tu
 
  Tukey multiple comparisons of means
    95% family-wise confidence level

Fit: aov(formula = resp ~ trat, data = morango)

$trat
          diff         lwr         upr     p adj
C-A  0.0501750 -0.01692822  0.11727822 0.1973032
G-A  0.2682250  0.20112178  0.33532822 0.0000000
L-A  0.0082875 -0.05881572  0.07539072 0.9865109
G-C  0.2180500  0.15094678  0.28515322 0.0000000
L-C -0.0418875 -0.10899072  0.02521572 0.3404304
L-G -0.2599375 -0.32704072 -0.19283428 0.0000000
 
Para visualização de forma gráfica, basta apenas fazer um plot do objeto morango.tu:
> plot(morango.tu)
 
excap7-004.png
No pacote agricolae há uma função que representa o resultado do teste de Tukey com as letras indicando os grupos.
> require(agricolae)
> df <- df.residual(morango.av)
> MSerror <- deviance(morango.av)/df
> tukey.tu <- HSD.test(morango$resp, morango$trat, df, MSerror, 
+     group = TRUE, main = "Comparação de médias - morango")
 
Study: Comparação de médias - morango

HSD Test for morango$resp 
                                          ......
Alpha                                0.050000000
Error Degrees of Freedom            28.000000000
Error Mean Square                    0.002416141
Critical Value of Studentized Range  3.861243662

Treatment Means
  morango.trat morango.resp    std.err replication
1            A    0.1711125 0.01162003           8
2            C    0.2212875 0.02418321           8
3            G    0.4393375 0.01797667           8
4            L    0.1794000 0.01284746           8

Honestly Significant Difference 0.06710322
Means with the same letter are not significantly different.

Groups, Treatments and means
a 	 G 	 0.4393375 
 b 	 C 	 0.2212875 
 b 	 L 	 0.1794 
 b 	 A 	 0.1711125 
 



File translated from TEX by TTH, version 3.67.
On 17 Jun 2009, 19:50.