Examen parcial:

Factorial simple completamente al azar

Factorial completo en arreglo completamente al azar

Factorial completo en bloques completamente al azar

Factorial completo en parcelas divididas

Factorial imcompleto completamnete al azar

Trabajo parcial:

Factorial incompleto en bloques con covariantes

Script desing

Trabajo final

Diseño en medidas repetidas

Diseño Lattice

Analisis de perfiles

Modelos efectos aleatorios y mixtos

Diseño en parcelas divididas

Deben haber dos factores como minimo Dos aleatorizaciones (Dos veces el experimento) Podria necesitar bloques

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 = paste(xy$f1, xy$f2, xy$rep )

library(ggplot2)

ggplot(xy)+
  aes(x, y, label=name, fill=f2)+
  geom_tile(color='white')+
  geom_text(fill='white')+
  labs(title = 'Completamente al azar')
## Warning in geom_text(fill = "white"): Ignoring unknown parameters: `fill`

library(dplyr)

xy = expand.grid(x = seq(6), y= seq(4))
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())

El anova debe tener 2 errores

set.seed(123)
data$biom = rnorm(24,8,2)

Analisis descrptivo

library(ggplot2)
ggplot(data)+
  aes(f2, biom)+
  geom_boxplot()

ggplot(data)+
  aes(f1, biom)+
  geom_boxplot()

ggplot(data)+
  aes(f2, biom, fill=f1)+
  geom_boxplot()

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
## f2  2 13.327   6.664
## f1  3  4.969   1.656
## 
## Error: Within
##           Df Sum Sq Mean Sq F value Pr(>F)
## f1         3   6.70   2.232   0.740  0.554
## f2:f1      6  32.45   5.409   1.794  0.207
## Residuals  9  27.14   3.016