Punto 1: ANOVA para especies de flores
# Crear los datos
setosa <- c(5.1, 4.9, 4.7, 4.6, 5, 5.4, 4.6, 5, 4.4, 4.9, 5.4, 4.8, 4.8, 4.3, 5.8)
versicolor <- c(7, 6.4, 6.9, 5.5, 6.5, 5.7, 6.3, 4.9, 6.6, 5.2, 5, 5.9, 6, 6.1, 5.6)
virginica <- c(6.3, 5.8, 7.1, 6.3, 6.5, 7.6, 4.9, 7.3, 6.7, 7.2, 6.5, 6.4, 6.8, 5.7, 5.8)
longitud <- c(setosa, versicolor, virginica)
especie <- factor(rep(c("Setosa", "Versicolor", "Virginica"), each = 15))
datos1 <- data.frame(longitud, especie)
# ANOVA
modelo1 <- aov(longitud ~ especie, data = datos1)
summary(modelo1)
## Df Sum Sq Mean Sq F value Pr(>F)
## especie 2 18.76 9.382 25.71 5.1e-08 ***
## Residuals 42 15.32 0.365
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Prueba LSD
library(agricolae)
lsd1 <- LSD.test(modelo1, "especie", p.adj = "none")
lsd1
## $statistics
## MSerror Df Mean CV t.value LSD
## 0.3648254 42 5.782222 10.44595 2.018082 0.4450929
##
## $parameters
## test p.ajusted name.t ntr alpha
## Fisher-LSD none especie 3 0.05
##
## $means
## longitud std r se LCL UCL Min Max Q25 Q50
## Setosa 4.913333 0.397971 15 0.1559541 4.598605 5.228062 4.3 5.8 4.65 4.9
## Versicolor 5.973333 0.656252 15 0.1559541 5.658605 6.288062 4.9 7.0 5.55 6.0
## Virginica 6.460000 0.710935 15 0.1559541 6.145272 6.774728 4.9 7.6 6.05 6.5
## Q75
## Setosa 5.05
## Versicolor 6.45
## Virginica 6.95
##
## $comparison
## NULL
##
## $groups
## longitud groups
## Virginica 6.460000 a
## Versicolor 5.973333 b
## Setosa 4.913333 c
##
## attr(,"class")
## [1] "group"
# Prueba Duncan
duncan1 <- duncan.test(modelo1, "especie", group = TRUE)
duncan1
## $statistics
## MSerror Df Mean CV
## 0.3648254 42 5.782222 10.44595
##
## $parameters
## test name.t ntr alpha
## Duncan especie 3 0.05
##
## $duncan
## Table CriticalRange
## 2 2.853999 0.4450929
## 3 3.001069 0.4680291
##
## $means
## longitud std r se Min Max Q25 Q50 Q75
## Setosa 4.913333 0.397971 15 0.1559541 4.3 5.8 4.65 4.9 5.05
## Versicolor 5.973333 0.656252 15 0.1559541 4.9 7.0 5.55 6.0 6.45
## Virginica 6.460000 0.710935 15 0.1559541 4.9 7.6 6.05 6.5 6.95
##
## $comparison
## NULL
##
## $groups
## longitud groups
## Virginica 6.460000 a
## Versicolor 5.973333 b
## Setosa 4.913333 c
##
## attr(,"class")
## [1] "group"
# Gráfico de barras con resultados Duncan
bar.group(duncan1$groups, ylim=c(0,8), main="Grupos según prueba de Duncan", ylab="Longitud media")

Punto 2: Tratamientos de cocción de frijoles
control <- c(213, 214, 204, 208, 212, 200, 207)
T2 <- c(76, 85, 74, 78, 82, 75, 82)
T3 <- c(57, 67, 55, 64, 61, 63, 63)
T4 <- c(84, 82, 85, 92, 87, 79, 90)
tiempo <- c(control, T2, T3, T4)
tratamiento <- factor(rep(c("Control", "T2", "T3", "T4"), each=7))
datos2 <- data.frame(tiempo, tratamiento)
modelo2 <- aov(tiempo ~ tratamiento, data = datos2)
summary(modelo2)
## Df Sum Sq Mean Sq F value Pr(>F)
## tratamiento 3 95041 31680 1559 <2e-16 ***
## Residuals 24 488 20
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lsd2 <- LSD.test(modelo2, "tratamiento", p.adj = "none")
lsd2
## $statistics
## MSerror Df Mean CV t.value LSD
## 20.32143 24 108.5357 4.153407 2.063899 4.973149
##
## $parameters
## test p.ajusted name.t ntr alpha
## Fisher-LSD none tratamiento 4 0.05
##
## $means
## tiempo std r se LCL UCL Min Max Q25 Q50
## Control 208.28571 5.122313 7 1.703837 204.76917 211.80226 200 214 205.5 208
## T2 78.85714 4.180453 7 1.703837 75.34060 82.37369 74 85 75.5 78
## T3 61.42857 4.157609 7 1.703837 57.91202 64.94512 55 67 59.0 63
## T4 85.57143 4.503967 7 1.703837 82.05488 89.08798 79 92 83.0 85
## Q75
## Control 212.5
## T2 82.0
## T3 63.5
## T4 88.5
##
## $comparison
## NULL
##
## $groups
## tiempo groups
## Control 208.28571 a
## T4 85.57143 b
## T2 78.85714 c
## T3 61.42857 d
##
## attr(,"class")
## [1] "group"
duncan2 <- duncan.test(modelo2, "tratamiento", group = TRUE)
duncan2
## $statistics
## MSerror Df Mean CV
## 20.32143 24 108.5357 4.153407
##
## $parameters
## test name.t ntr alpha
## Duncan tratamiento 4 0.05
##
## $duncan
## Table CriticalRange
## 2 2.918793 4.973148
## 3 3.065610 5.223301
## 4 3.159874 5.383910
##
## $means
## tiempo std r se Min Max Q25 Q50 Q75
## Control 208.28571 5.122313 7 1.703837 200 214 205.5 208 212.5
## T2 78.85714 4.180453 7 1.703837 74 85 75.5 78 82.0
## T3 61.42857 4.157609 7 1.703837 55 67 59.0 63 63.5
## T4 85.57143 4.503967 7 1.703837 79 92 83.0 85 88.5
##
## $comparison
## NULL
##
## $groups
## tiempo groups
## Control 208.28571 a
## T4 85.57143 b
## T2 78.85714 c
## T3 61.42857 d
##
## attr(,"class")
## [1] "group"
Punto 3: Comparación de sistemas de cultivo (Diseño en bloques)
rendimiento <- c(5.5,5.5,6.9,7.2, 5.8,5.3,5.6,4.1, 6.9,5.3,6.6,4.5, 5.0,7.2,6.1,7.0, 6.2,5.7,4.8,5.8)
trat <- factor(rep(c("C","A","B","D"),5))
bloque <- factor(rep(1:5, each=4))
datos3 <- data.frame(rendimiento, trat, bloque)
modelo3 <- aov(rendimiento ~ trat + bloque, data = datos3)
summary(modelo3)
## Df Sum Sq Mean Sq F value Pr(>F)
## trat 3 0.214 0.0713 0.072 0.974
## bloque 4 3.520 0.8800 0.892 0.498
## Residuals 12 11.836 0.9863
duncan3 <- duncan.test(modelo3, "trat", group = TRUE)
duncan3
## $statistics
## MSerror Df Mean CV
## 0.9863333 12 5.85 16.97681
##
## $parameters
## test name.t ntr alpha
## Duncan trat 4 0.05
##
## $duncan
## Table CriticalRange
## 2 3.081307 1.368553
## 3 3.225244 1.432483
## 4 3.312453 1.471216
##
## $means
## rendimiento std r se Min Max Q25 Q50 Q75
## A 5.80 0.8000000 5 0.4441471 5.3 7.2 5.3 5.5 5.7
## B 6.00 0.8336666 5 0.4441471 4.8 6.9 5.6 6.1 6.6
## C 5.88 0.7190271 5 0.4441471 5.0 6.9 5.5 5.8 6.2
## D 5.72 1.4096099 5 0.4441471 4.1 7.2 4.5 5.8 7.0
##
## $comparison
## NULL
##
## $groups
## rendimiento groups
## B 6.00 a
## C 5.88 a
## A 5.80 a
## D 5.72 a
##
## attr(,"class")
## [1] "group"