CLASE
En esencia es hacer dos veces el mismo experimento, pues hay que hacer dos aleatorizaciones.
Es común en problemas de riego por goteo, fertilización, densidad de siembra, investigaciones con el uso de maquinaria.
Es frecuente en agricultura
#Completamente al azar, solo hay una aleatorización.
#Y es díficil establecerlo, ¿cómo meter varios riegos en
#una parcela, muy complicado
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.2.2
##
## 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:4))
xy$rep = gl(2, 1, 24, paste0('r', 1:4))
xy$name = paste0(xy$f1, xy$f2, xy$rep)
xy
## x y f1 f2 rep name
## 1 4 4 v1 R1 r1 v1R1r1
## 2 5 2 v1 R1 r2 v1R1r2
## 3 2 3 v1 R2 r1 v1R2r1
## 4 4 2 v1 R2 r2 v1R2r2
## 5 1 4 v1 R3 r1 v1R3r1
## 6 3 1 v1 R3 r2 v1R3r2
## 7 1 1 v2 R1 r1 v2R1r1
## 8 4 3 v2 R1 r2 v2R1r2
## 9 4 1 v2 R2 r1 v2R2r1
## 10 5 4 v2 R2 r2 v2R2r2
## 11 6 2 v2 R3 r1 v2R3r1
## 12 2 1 v2 R3 r2 v2R3r2
## 13 6 3 v3 R1 r1 v3R1r1
## 14 3 4 v3 R1 r2 v3R1r2
## 15 2 2 v3 R2 r1 v3R2r1
## 16 1 2 v3 R2 r2 v3R2r2
## 17 5 1 v3 R3 r1 v3R3r1
## 18 3 2 v3 R3 r2 v3R3r2
## 19 6 1 v4 R1 r1 v4R1r1
## 20 2 4 v4 R1 r2 v4R1r2
## 21 1 3 v4 R2 r1 v4R2r1
## 22 5 3 v4 R2 r2 v4R2r2
## 23 6 4 v4 R3 r1 v4R3r1
## 24 3 3 v4 R3 r2 v4R3r2
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.2.2
ggplot(xy)+
aes (x, y, label = name, fill = f2)+
geom_tile(color = 'white')+
geom_text(fill = 'white')
## Warning in geom_text(fill = "white"): Ignoring unknown parameters: `fill`
labs (title = 'Completamente al azar')
## $title
## [1] "Completamente al azar"
##
## attr(,"class")
## [1] "labels"
Ya es diseño en parcelas Doble aleatorización, una para riego, y otra para variedad.
Se escogen 4 parcelas para el riego, siendo cada una para un riego diferente, y luego dentro de cada parcela se aleatorizan las variedades, hay dos aleatorizaciones, una para riegos al estar en diferentes parcelas y dentro de cada una se aleatorizan las variedades.
Tienes dos errores, uno para la parcela principal, y otro para las subparcelas
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())
## Análisis descriptivo
set.seed(123)
data$biom = rnorm(24,8,2)
## Analisis descriptivo
ggplot(data)+aes(f2,biom)+geom_boxplot()
ggplot(data)+aes(f1,biom)+geom_boxplot()
ggplot(data)+aes(f2,biom, fill=f1)+geom_boxplot()
library(lme4)
## Warning: package 'lme4' was built under R version 4.2.3
## Loading required package: Matrix
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 13.327 6.664 8.078 0.062 .
## Residuals 3 2.475 0.825
## ---
## 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 3.71 1.237 1.286 0.33710
## f2:f1 6 56.41 9.402 9.775 0.00162 **
## Residuals 9 8.66 0.962
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
La hipotesis es que no hay interacción, p-valor >5%, no se rechaza la hipotesis, no hay interacción.
Si no hay interacción se pueden interpretar los valores de arriba del anova
En el riego p-valor >5%, no rechazo, es decir que la biomasa no cambió por las variedades
En la variedad p-valor >5%, no rechazo, es decir que la biomasa no cambió por las variedades
Riego = f1, variedad = f2