##Diseño Cuadrado Latino ###factorial simple en bloques al azar (FSBA)
Un solo un factor Dos razones de bloqueo
lote <- c(rep("Lote1",1), rep("Lote2",1), rep("Lote3",1), rep("Lote4",1), rep("Lote5",1))
genotipo <- c(rep("genA",5), rep("genB",5), rep("genC",5), rep("genD",5), rep("genE",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(genotipo, lote, prov, biom)
head (data)
###Gráficos descriptivos
library(lattice)
bwplot(biom ~ genotipo | prov + lote,
data)
##Modelo
\[y= \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
\[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)
bwplot(biom ~ genotipo | prov,
data)
interaction.plot(genotipo, prov, biom, lwd=2)
library(ggplot2)
ggplot(data)+aes (x= prov, y= biom, fill=genotipo)+ geom_col( position = 'dodge')
#Revisión de supuesto
res_mod = mod$residuals
#1. Normalidad
shapiro.test(res_mod)
#Se cumple el supuesto de normalidad
#2.Igualdad de varianzas
bartlett.test(res_mod, genotipo)
#Se cumple el supuesto (Varianzas iguales)
#install.packages("TuckeyC)
library(TukeyC)
tt = TukeyC(mod, 'genotipo')
plot(tt)