lote <- c(rep("lote1", 1),
rep("lote2", 1),
rep("lote3", 1),
rep("lote4", 1),
rep("lote5", 1)
)
genotipo <- c(rep("genotA",5),
rep("genotB",5),
rep("genotC",5),
rep("genotD",5),
rep("genotE",5)
)
prov <- c("A","E","C","B","D",
"C","B","A","D","E",
"B","C","D","E","A",
"D","A","E","C","B",
"E","D","B","A","C")
biom <- c(42,45,41,56,47, 47,
54,46,52,49, 55,52,
57,49,45, 51,44,47,
50,54, 44,50,48,43,
46)
data <- data.frame(
lote, genotipo, prov, biom)
head(data)
## lote genotipo prov biom
## 1 lote1 genotA A 42
## 2 lote2 genotA E 45
## 3 lote3 genotA C 41
## 4 lote4 genotA B 56
## 5 lote5 genotA D 47
## 6 lote1 genotB C 47
Gráficos descriptivos
library(lattice)
bwplot(biom ~ lote | prov +
lote, data, las = 2)
Modelo
\[y_{ijk} = \mu + \tau_i + \beta_j + \delta_k + \epsilon_{ijk}\]
\[i = 1, \dots, p\] \[j = 1, \dots, p\] \[k = 1, \dots, p\]
tbl = matrix(data$prov, 5)
colnames (tbl)= unique (data$genotipo)
rownames (tbl) = unique (data$lote)
tbl
## genotA genotB genotC genotD genotE
## lote1 "A" "C" "B" "D" "E"
## lote2 "E" "B" "C" "A" "D"
## lote3 "C" "A" "D" "E" "B"
## lote4 "B" "D" "E" "C" "A"
## lote5 "D" "E" "A" "B" "C"
Hipotesis
\[H_0: \mu_{B_{g_1}} = \mu_{B_{g_2}} = \mu_{B_{g_3}} = \mu_{B_{g_4}} = \mu_{B_{g_5}}\]
mod <- lm(biom ~ lote + genotipo + prov,
data)
anova(mod)
## Analysis of Variance Table
##
## Response: biom
## Df Sum Sq Mean Sq F value Pr(>F)
## lote 4 17.76 4.440 0.7967 0.549839
## genotipo 4 109.36 27.340 4.9055 0.014105 *
## prov 4 286.16 71.540 12.8361 0.000271 ***
## Residuals 12 66.88 5.573
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Comportamiento de los genotipos según el proveedor
bwplot(biom ~ genotipo | prov,
data)
interaction.plot(genotipo,
prov,
biom,
lwd = 2)
plot(factor(genotipo), biom, col = factor(prov))
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.2.2
ggplot(data) +
aes(genotipo,
biom,
fill = prov)+
geom_col(
position = 'dodge'
)
Se rechaza Ho porque no todos los genotipos son iguales y si quiero escoger entre todos, escogería el proveedor D y genotipo C, ya que es el que posee las barras más altas, además, no recomedaría el proveedor A.
Revisión de supuestos
res_mod = mod$residuals
# 1. Normalidad
shapiro.test(res_mod)
##
## Shapiro-Wilk normality test
##
## data: res_mod
## W = 0.97691, p-value = 0.8178
# 2. Igualdad de varianzas
bartlett.test(res_mod,
genotipo)
##
## Bartlett test of homogeneity of variances
##
## data: res_mod and genotipo
## Bartlett's K-squared = 5.9223, df = 4, p-value = 0.205
# Se cumple el supuesto (varianza iguales)
# install.packages("TukeyC")
library(TukeyC)
## Warning: package 'TukeyC' was built under R version 4.2.3
tt = TukeyC (mod, 'genotipo')
plot(tt)
Estadisticamente, analizando el grafico de TukeyC los genotipos A y E tiene malos rendimientos, por otro lado, el genotipo C es el que tiene mejor redimiento.