#Parcelas Divididas
#Diseños visto: 1. Factorial completo en arreglo completamente al azar 2. FactoriaL completo en bloques al azar 3. Factorial completo en parcelas divididas 4. Fcatorial incompleto completamente al azar
Para el segundo trabajo: - Factorial incompleto en bloques con covariables - Strip Plot Design
Para el tercer parcial: - Diseño de medias repetidas - Diseño Lattice - Análisis de pérfiles - Diseño de efectos aleatorios y mixtos
#PARCELAS DIVIDIDAS (FCPD) (SPLIT PLOT DESIGN) ¿Qué requiere? 1. Qué hayan 2 factores por lo mínimo 2. Hay que hacer dos aleatorizaciones (parecido a hacer dos veces el experimento) 3. Común en problemas de riego, fertilización, densidad de siembra, maquinaria. 4. Podría necesitar bloques pero puede que no.
Hay gente que toma como factor las parcelas, factor 1: parcela. Y la cantidad de parcelas serían los niveles. Pero hay otras personas que las consideran más como bloques, porque consideran que al ser un factor algo que uno controla las parcelas no se pueden controlar.
Ej1: Factor 1: Parcela (s1, s2, s3) Factor 2: Fertlización (Fo, F1, F2)
#Completamente al axar, difícil de establecer en campo
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
xy = expand.grid(x = seq(6), y = seq(4))
xy = sample_frac(xy)
xy$f1 = gl(4, 6, 24, paste0('V',1:4))
xy$f2 = gl(3, 2, 24, paste0('R',1:3))
xy$rep = gl(2, 1, 24, paste0('r',1:2))
xy$name = paste0(xy$f1, xy$f2, xy$rep)
xy
## x y f1 f2 rep name
## 1 1 1 V1 R1 r1 V1R1r1
## 2 5 1 V1 R1 r2 V1R1r2
## 3 3 4 V1 R2 r1 V1R2r1
## 4 3 3 V1 R2 r2 V1R2r2
## 5 5 4 V1 R3 r1 V1R3r1
## 6 1 3 V1 R3 r2 V1R3r2
## 7 4 2 V2 R1 r1 V2R1r1
## 8 2 1 V2 R1 r2 V2R1r2
## 9 5 3 V2 R2 r1 V2R2r1
## 10 2 3 V2 R2 r2 V2R2r2
## 11 1 4 V2 R3 r1 V2R3r1
## 12 3 1 V2 R3 r2 V2R3r2
## 13 2 4 V3 R1 r1 V3R1r1
## 14 6 3 V3 R1 r2 V3R1r2
## 15 6 4 V3 R2 r1 V3R2r1
## 16 3 2 V3 R2 r2 V3R2r2
## 17 2 2 V3 R3 r1 V3R3r1
## 18 6 1 V3 R3 r2 V3R3r2
## 19 1 2 V4 R1 r1 V4R1r1
## 20 4 3 V4 R1 r2 V4R1r2
## 21 4 4 V4 R2 r1 V4R2r1
## 22 5 2 V4 R2 r2 V4R2r2
## 23 4 1 V4 R3 r1 V4R3r1
## 24 6 2 V4 R3 r2 V4R3r2
#Este no me sirve
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.2.3
ggplot(xy)+
aes(x,y,label=name, fill=f2)+
geom_tile(color='white')+
geom_label(fill='white')+
labs(title = 'Completamente al azar')
#Este es el que realmente sirve
library(dplyr)
xy = expand.grid(y = seq(4), x = seq(6))
f2 = gl(3, 8, 24, paste0('R',1:3))
lf1 = paste0('V',1:4)
f1 = c(sample(lf1),sample(lf1),
sample(lf1),sample(lf1),
sample(lf1),sample(lf1))
rep = rep(rep(paste0('r',1:2), each=4), 3)
data = data.frame(xy, f1, f2, rep)
data$name = with(data, paste0(f1, rep))
library(ggplot2)
ggplot(data)+
aes(x,y,label=name, fill=f1)+
geom_tile(color='white')+
geom_text()+
facet_wrap(~f2, scales = 'free')+
theme(axis.text = element_blank())
Modelo estadístico \[Yijk = \mu +\alpha_i + \lambda_k(i) + \beta_j + (\alpha\beta)_ij + \epsilon_k(ij)\]
El ANOVA de este modelo debe tener dos errores.
#Análisis descriptivo
set.seed(123)
data$biom = rnorm(24, 8, 2)
ggplot(data)+
aes(f2, biom)+
geom_boxplot()
ggplot(data)+
aes(f1, biom)+
geom_boxplot()
ggplot(data)+
aes(f2, biom, fill=f1)+
geom_boxplot()
#ANOVA
set.seed(123)
data$biom = rnorm(24)
library(lme4)
## Warning: package 'lme4' was built under R version 4.2.3
## Loading required package: Matrix
#mod1 = lmer(biom ~ rep + f2*f1 + (1|f2), data)
#Enfoque viejo
mod1 = aov(biom ~ f2 * f1 + Error(f2:rep), data)
## Warning in aov(biom ~ f2 * f1 + Error(f2:rep), data): Error() model is singular
summary(mod1)
##
## Error: f2:rep
## Df Sum Sq Mean Sq F value Pr(>F)
## f2 2 3.332 1.6659 8.078 0.062 .
## Residuals 3 0.619 0.2062
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Error: Within
## Df Sum Sq Mean Sq F value Pr(>F)
## f1 3 4.435 1.4784 1.950 0.192
## f2:f1 6 5.938 0.9896 1.305 0.345
## Residuals 9 6.823 0.7581
#Siempre se debe ver la interacción primero. Si hay interacción se interpretan los de arriba. Ho = No hay interación. La hipótesis nula se rechaza con el 5%.