Professional Documents
Culture Documents
ANOVA y Tukey
ANOVA y Tukey
ANOVA y Tukey
This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath
the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it
and pressing Ctrl+Shift+Enter.
Cargar paquetes
library(ggplot2)
library(dplyr)
##
## Attaching package: ’dplyr’
library(agricolae)
library(car)
##
## Attaching package: ’car’
library(FSA)
##
## Attaching package: ’FSA’
1
## The following object is masked from ’package:car’:
##
## bootCase
data(PlantGrowth)
PlantGrowth
## weight group
## 1 4.17 ctrl
## 2 5.58 ctrl
## 3 5.18 ctrl
## 4 6.11 ctrl
## 5 4.50 ctrl
## 6 4.61 ctrl
## 7 5.17 ctrl
## 8 4.53 ctrl
## 9 5.33 ctrl
## 10 5.14 ctrl
## 11 4.81 trt1
## 12 4.17 trt1
## 13 4.41 trt1
## 14 3.59 trt1
## 15 5.87 trt1
## 16 3.83 trt1
## 17 6.03 trt1
## 18 4.89 trt1
## 19 4.32 trt1
## 20 4.69 trt1
## 21 6.31 trt2
## 22 5.12 trt2
## 23 5.54 trt2
## 24 5.50 trt2
## 25 5.37 trt2
## 26 5.29 trt2
## 27 4.92 trt2
## 28 6.15 trt2
## 29 5.80 trt2
## 30 5.26 trt2
Prueba de Normalidad
hist(PlantGrowth$weight)
2
Histogram of PlantGrowth$weight
8
6
Frequency
4
2
0
PlantGrowth$weight
shapiro.test(PlantGrowth$weight)
##
## Shapiro-Wilk normality test
##
## data: PlantGrowth$weight
## W = 0.98268, p-value = 0.8915
qqPlot(PlantGrowth$weight)
3
6.0
PlantGrowth$weight
5.5
5.0
4.5
4.0
16
14
3.5
−2 −1 0 1 2
norm quantiles
## [1] 14 16
Prueba de homocedasticidad, se pueden utilizar la prueba de Levene y la prueba de Bartlett para conocer si
nuestros datos presentan homocedasticidad.
Si nuestros datos presentan normalidad lo mas recomendable es utilizar la prueba de Bartlett.
Test de Bartlett
##
## Bartlett test of homogeneity of variances
##
## data: weight by group
## Bartlett’s K-squared = 2.8786, df = 2, p-value = 0.2371
Test de Levene
4
Prueba de ANOVA, realizamos la prueba de anova para conocer si exiten diferencias significativas del peso
de las plantas de acuerdo al tratamiento.
planta_modelo<-aov(weight~group,PlantGrowth)
summary(planta_modelo)
Prueba de Tukey, realizamos la prueba post hoc para conocer entre cuales grupos hay diferencias significativas
TukeyHSD(planta_modelo,"group")
Prueba de Duncan, realizamos la prueba post hoc (lternativa a la prueba de Tukey) para conocer entre cuales
grupos hay diferencias significativas
Plantas_ducan<-duncan.test(planta_modelo,"group",alpha=0.01,console=TRUE)
##
## Study: planta_modelo ~ "group"
##
## Duncan’s new multiple range test
## for weight
##
## Mean Square Error: 0.3885959
##
## group, means
##
## weight std r Min Max
## ctrl 5.032 0.5830914 10 4.17 6.11
## trt1 4.661 0.7936757 10 3.59 6.03
## trt2 5.526 0.4425733 10 4.92 6.31
##
## Alpha: 0.01 ; DF Error: 27
##
## Critical Range
## 2 3
5
## 0.7724154 0.8055987
##
## Means with the same letter are not significantly different.
##
## weight groups
## trt2 5.526 a
## ctrl 5.032 ab
## trt1 4.661 b
plot(Plantas_ducan)
a
ab b
6
5
4
3
6
Realizamos el grafico con ggplot
4
peso
7
width = 0.5,
size = 0.5)
4
group
ctrl
peso
trt1
trt2
2
8
diferencia por grupo
Sub titulo
4
peso