Diseño de bloques completamente aleatorizados

Datos

Colocaremos los datos en forma de vectores

y <- c(40.89,41.22,44.57,41.9,37.99,49.42,52.68,39.2,37.18,45.85,37.61,43.29,39.98,50.15,36.94,40.45,34.89,41.99,46.65,42.91,42.07,46.69,40.23,39.97)

trat <- factor(rep(1:6, each = 4))

bloq <- factor(rep(1:4,6))

Armamos nuestro data en formato data.frame

(datos <- data.frame(y,trat,bloq))
##        y trat bloq
## 1  40.89    1    1
## 2  41.22    1    2
## 3  44.57    1    3
## 4  41.90    1    4
## 5  37.99    2    1
## 6  49.42    2    2
## 7  52.68    2    3
## 8  39.20    2    4
## 9  37.18    3    1
## 10 45.85    3    2
## 11 37.61    3    3
## 12 43.29    3    4
## 13 39.98    4    1
## 14 50.15    4    2
## 15 36.94    4    3
## 16 40.45    4    4
## 17 34.89    5    1
## 18 41.99    5    2
## 19 46.65    5    3
## 20 42.91    5    4
## 21 42.07    6    1
## 22 46.69    6    2
## 23 40.23    6    3
## 24 39.97    6    4

Análisis descriptivo

library(psych)
describeBy(x = datos$y,group = datos$trat)
## 
##  Descriptive statistics by group 
## group: 1
##    vars n  mean   sd median trimmed  mad   min   max range skew kurtosis   se
## X1    1 4 42.14 1.67  41.56   42.14 0.75 40.89 44.57  3.68 0.62    -1.79 0.84
## ------------------------------------------------------------ 
## group: 2
##    vars n  mean   sd median trimmed  mad   min   max range skew kurtosis   se
## X1    1 4 44.82 7.33  44.31   44.82 8.47 37.99 52.68 14.69 0.05    -2.36 3.66
## ------------------------------------------------------------ 
## group: 3
##    vars n  mean   sd median trimmed  mad   min   max range skew kurtosis   se
## X1    1 4 40.98 4.28  40.45   40.98 4.53 37.18 45.85  8.67 0.11    -2.31 2.14
## ------------------------------------------------------------ 
## group: 4
##    vars n  mean   sd median trimmed mad   min   max range skew kurtosis   se
## X1    1 4 41.88 5.73  40.22   41.88 2.6 36.94 50.15 13.21 0.58    -1.77 2.86
## ------------------------------------------------------------ 
## group: 5
##    vars n  mean   sd median trimmed  mad   min   max range  skew kurtosis   se
## X1    1 4 41.61 4.91  42.45   41.61 3.45 34.89 46.65 11.76 -0.37    -1.85 2.46
## ------------------------------------------------------------ 
## group: 6
##    vars n  mean   sd median trimmed  mad   min   max range skew kurtosis   se
## X1    1 4 42.24 3.11  41.15   42.24 1.56 39.97 46.69  6.72 0.57    -1.84 1.56

Al parecer teniendo en cuenta las medidas estadísticas encontradas, al parecer el programa 1 es mejor al tener una menor variabilidad, también se observa que el error estándar del programa 1 es menor lo que indica que justamente que los resultados obtenidos con ese programas son más estables.

library(ggplot2)
## 
## Adjuntando el paquete: 'ggplot2'
## The following objects are masked from 'package:psych':
## 
##     %+%, alpha
library(dplyr)
## 
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
(g1 <- datos %>% ggplot(aes(x = trat, y = y, fill = trat)) + geom_boxplot() + labs(title = "Diagrama de cajas", y = "contenido de nitrógeno en espigas de trigo", x = "Programa de nitrógeno"))

El programa 2 genera mayor dispersión (mayor variabilidad), también se observa que con el programa 2 se está generando mayor contenido de nitrógeno, ¿Será confiable?.

(g2 <- datos %>% ggplot(aes(x = bloq, y = y , fill = bloq)) + geom_boxplot() + 
   labs(title = "Diagrama de cajas", y = "contenido de nitrógeno en espigas de trigo", x = "Gradiente del agua en dirección del área experimental"))

Dado que tenemos medianas diferentes, se podría decir que los bloques están influyendo significativamente a nuestro diseño, tambien se observa que en el grupo 2 en este bloque las condiciones hayan favorecido un mayor contenido de nitrógeno al tener una mayor altura, en el gradiente 1 se observa lo contrario; en la gradiente 3 se observa mayor dispersión indicando mayor variabilidad dentro de ese bloqueo.

Modelo Aditivo lineal

\(Y_{ij} = \mu + \tau_{i} + \beta_{j} + \epsilon_{ij}\)

\(Y_{ij}\) = Contenido de nitrógeno en espigas de trigo (en ppm) realizado con el i-ésimo programas de aplicación de nitrógeno aplicado en la j-ésima gradiente de agua en dirección del área de parcelas experimentales

\(\mu\) = Media global del contenido de nitrógeno en espigas de trigo (en ppm)

\(\tau_{i}\) : Efecto del i-ésimo programa de nitrógeno.

\(\beta_{j}\) : Efecto de la j-ésima gradiente de agua.

\(\epsilon_{ij}\) : Error experimental del contenido de nitrógeno al aplicarse el i-ésimo programas de aplicación de nitrógeno aplicado en la j-ésima gradiente de agua en dirección del área de parcelas experimentales.

modelo <- lm(y~ trat + bloq)

Supuestos

Normalidad

\(H_{0}\) : Los errores se distribuyen normalmente

\(H_{1}\) : Los errores no se distribuyen normalmente

modelo %>% residuals() %>%  shapiro.test()
## 
##  Shapiro-Wilk normality test
## 
## data:  .
## W = 0.96486, p-value = 0.5434

Decisión : No se rechaza la hipótesis nula

Conclusión: A un nivel de significancia del 5%, se puede afirmar que los errores se distribuyen normalmente

Homogeneidad

\(H_{0}\) : \(\sigma_{1}^2 =\sigma_{2}^2=\sigma_{3}^2 = \sigma_{4}^2 = \sigma_{5}^2=\sigma_{6}^2\)

\(H_{1}\) : Al menos una varianza es diferente a los demás

bartlett.test(x = modelo$residuals, g = datos$trat)
## 
##  Bartlett test of homogeneity of variances
## 
## data:  modelo$residuals and datos$trat
## Bartlett's K-squared = 1.7302, df = 5, p-value = 0.8851

Decisión : No se rechaza la hipótesis nula

Conclusión: A un nivel de significancia del 5%, se puede afirmar que las varianzas de los errores son homogéneos.

Pruebas de comparación

##LSD

library(agricolae)
LSD.test(modelo, "trat", alpha = 0.05, console = T)
## 
## Study: modelo ~ "trat"
## 
## LSD t Test for y 
## 
## Mean Square Error:  17.6568 
## 
## trat,  means and individual ( 95 %) CI
## 
##         y      std r    se      LCL      UCL   Min   Max     Q25    Q50     Q75
## 1 42.1450 1.670459 4 2.101 37.66683 46.62317 40.89 44.57 41.1375 41.560 42.5675
## 2 44.8225 7.329686 4 2.101 40.34433 49.30067 37.99 52.68 38.8975 44.310 50.2350
## 3 40.9825 4.275897 4 2.101 36.50433 45.46067 37.18 45.85 37.5025 40.450 43.9300
## 4 41.8800 5.728624 4 2.101 37.40183 46.35817 36.94 50.15 39.2200 40.215 42.8750
## 5 41.6100 4.912379 4 2.101 37.13183 46.08817 34.89 46.65 40.2150 42.450 43.8450
## 6 42.2400 3.110434 4 2.101 37.76183 46.71817 39.97 46.69 40.1650 41.150 43.2250
## 
## Alpha: 0.05 ; DF Error: 15
## Critical Value of t: 2.13145 
## 
## least Significant Difference: 6.333096 
## 
## Treatments with the same letter are not significantly different.
## 
##         y groups
## 2 44.8225      a
## 6 42.2400      a
## 1 42.1450      a
## 4 41.8800      a
## 5 41.6100      a
## 3 40.9825      a
LSD.test(modelo, "trat", alpha = 0.05, console = T, group = F)
## 
## Study: modelo ~ "trat"
## 
## LSD t Test for y 
## 
## Mean Square Error:  17.6568 
## 
## trat,  means and individual ( 95 %) CI
## 
##         y      std r    se      LCL      UCL   Min   Max     Q25    Q50     Q75
## 1 42.1450 1.670459 4 2.101 37.66683 46.62317 40.89 44.57 41.1375 41.560 42.5675
## 2 44.8225 7.329686 4 2.101 40.34433 49.30067 37.99 52.68 38.8975 44.310 50.2350
## 3 40.9825 4.275897 4 2.101 36.50433 45.46067 37.18 45.85 37.5025 40.450 43.9300
## 4 41.8800 5.728624 4 2.101 37.40183 46.35817 36.94 50.15 39.2200 40.215 42.8750
## 5 41.6100 4.912379 4 2.101 37.13183 46.08817 34.89 46.65 40.2150 42.450 43.8450
## 6 42.2400 3.110434 4 2.101 37.76183 46.71817 39.97 46.69 40.1650 41.150 43.2250
## 
## Alpha: 0.05 ; DF Error: 15
## Critical Value of t: 2.13145 
## 
## Comparison between treatments means
## 
##       difference pvalue signif.       LCL       UCL
## 1 - 2    -2.6775 0.3818         -9.010596  3.655596
## 1 - 3     1.1625 0.7011         -5.170596  7.495596
## 1 - 4     0.2650 0.9301         -6.068096  6.598096
## 1 - 5     0.5350 0.8595         -5.798096  6.868096
## 1 - 6    -0.0950 0.9749         -6.428096  6.238096
## 2 - 3     3.8400 0.2158         -2.493096 10.173096
## 2 - 4     2.9425 0.3377         -3.390596  9.275596
## 2 - 5     3.2125 0.2967         -3.120596  9.545596
## 2 - 6     2.5825 0.3985         -3.750596  8.915596
## 3 - 4    -0.8975 0.7668         -7.230596  5.435596
## 3 - 5    -0.6275 0.8356         -6.960596  5.705596
## 3 - 6    -1.2575 0.6781         -7.590596  5.075596
## 4 - 5     0.2700 0.9288         -6.063096  6.603096
## 4 - 6    -0.3600 0.9052         -6.693096  5.973096
## 5 - 6    -0.6300 0.8349         -6.963096  5.703096
LSD.test(modelo, "trat", alpha = 0.05, console = T, p.adj = "bonferroni")
## 
## Study: modelo ~ "trat"
## 
## LSD t Test for y 
## P value adjustment method: bonferroni 
## 
## Mean Square Error:  17.6568 
## 
## trat,  means and individual ( 95 %) CI
## 
##         y      std r    se      LCL      UCL   Min   Max     Q25    Q50     Q75
## 1 42.1450 1.670459 4 2.101 37.66683 46.62317 40.89 44.57 41.1375 41.560 42.5675
## 2 44.8225 7.329686 4 2.101 40.34433 49.30067 37.99 52.68 38.8975 44.310 50.2350
## 3 40.9825 4.275897 4 2.101 36.50433 45.46067 37.18 45.85 37.5025 40.450 43.9300
## 4 41.8800 5.728624 4 2.101 37.40183 46.35817 36.94 50.15 39.2200 40.215 42.8750
## 5 41.6100 4.912379 4 2.101 37.13183 46.08817 34.89 46.65 40.2150 42.450 43.8450
## 6 42.2400 3.110434 4 2.101 37.76183 46.71817 39.97 46.69 40.1650 41.150 43.2250
## 
## Alpha: 0.05 ; DF Error: 15
## Critical Value of t: 3.483677 
## 
## Minimum Significant Difference: 10.35092 
## 
## Treatments with the same letter are not significantly different.
## 
##         y groups
## 2 44.8225      a
## 6 42.2400      a
## 1 42.1450      a
## 4 41.8800      a
## 5 41.6100      a
## 3 40.9825      a

Tukey

HSD.test(modelo, "trat", alpha = 0.05, console = T)
## 
## Study: modelo ~ "trat"
## 
## HSD Test for y 
## 
## Mean Square Error:  17.6568 
## 
## trat,  means
## 
##         y      std r    se   Min   Max     Q25    Q50     Q75
## 1 42.1450 1.670459 4 2.101 40.89 44.57 41.1375 41.560 42.5675
## 2 44.8225 7.329686 4 2.101 37.99 52.68 38.8975 44.310 50.2350
## 3 40.9825 4.275897 4 2.101 37.18 45.85 37.5025 40.450 43.9300
## 4 41.8800 5.728624 4 2.101 36.94 50.15 39.2200 40.215 42.8750
## 5 41.6100 4.912379 4 2.101 34.89 46.65 40.2150 42.450 43.8450
## 6 42.2400 3.110434 4 2.101 39.97 46.69 40.1650 41.150 43.2250
## 
## Alpha: 0.05 ; DF Error: 15 
## Critical Value of Studentized Range: 4.594735 
## 
## Minimun Significant Difference: 9.653536 
## 
## Treatments with the same letter are not significantly different.
## 
##         y groups
## 2 44.8225      a
## 6 42.2400      a
## 1 42.1450      a
## 4 41.8800      a
## 5 41.6100      a
## 3 40.9825      a

SNK

SNK.test(modelo, "trat", alpha = 0.05, console = T)
## 
## Study: modelo ~ "trat"
## 
## Student Newman Keuls Test
## for y 
## 
## Mean Square Error:  17.6568 
## 
## trat,  means
## 
##         y      std r    se   Min   Max     Q25    Q50     Q75
## 1 42.1450 1.670459 4 2.101 40.89 44.57 41.1375 41.560 42.5675
## 2 44.8225 7.329686 4 2.101 37.99 52.68 38.8975 44.310 50.2350
## 3 40.9825 4.275897 4 2.101 37.18 45.85 37.5025 40.450 43.9300
## 4 41.8800 5.728624 4 2.101 36.94 50.15 39.2200 40.215 42.8750
## 5 41.6100 4.912379 4 2.101 34.89 46.65 40.2150 42.450 43.8450
## 6 42.2400 3.110434 4 2.101 39.97 46.69 40.1650 41.150 43.2250
## 
## Alpha: 0.05 ; DF Error: 15 
## 
## Critical Range
##        2        3        4        5        6 
## 6.333095 7.717765 8.563620 9.175034 9.653536 
## 
## Means with the same letter are not significantly different.
## 
##         y groups
## 2 44.8225      a
## 6 42.2400      a
## 1 42.1450      a
## 4 41.8800      a
## 5 41.6100      a
## 3 40.9825      a

Duncan

duncan.test(modelo, "trat", alpha = 0.05, console = T)
## 
## Study: modelo ~ "trat"
## 
## Duncan's new multiple range test
## for y 
## 
## Mean Square Error:  17.6568 
## 
## trat,  means
## 
##         y      std r    se   Min   Max     Q25    Q50     Q75
## 1 42.1450 1.670459 4 2.101 40.89 44.57 41.1375 41.560 42.5675
## 2 44.8225 7.329686 4 2.101 37.99 52.68 38.8975 44.310 50.2350
## 3 40.9825 4.275897 4 2.101 37.18 45.85 37.5025 40.450 43.9300
## 4 41.8800 5.728624 4 2.101 36.94 50.15 39.2200 40.215 42.8750
## 5 41.6100 4.912379 4 2.101 34.89 46.65 40.2150 42.450 43.8450
## 6 42.2400 3.110434 4 2.101 39.97 46.69 40.1650 41.150 43.2250
## 
## Alpha: 0.05 ; DF Error: 15 
## 
## Critical Range
##        2        3        4        5        6 
## 6.333095 6.638794 6.828770 6.958192 7.051004 
## 
## Means with the same letter are not significantly different.
## 
##         y groups
## 2 44.8225      a
## 6 42.2400      a
## 1 42.1450      a
## 4 41.8800      a
## 5 41.6100      a
## 3 40.9825      a

Dunnett

Como testigo tomaremos el tratamiento 1

library(DescTools)
## 
## Adjuntando el paquete: 'DescTools'
## The following objects are masked from 'package:psych':
## 
##     AUC, ICC, SD
DunnettTest(x = y, g = trat, control = "1")
## 
##   Dunnett's test for comparing several treatments with a control :  
##     95% family-wise confidence level
## 
## $`1`
##        diff     lwr.ci    upr.ci   pval    
## 2-1  2.6775  -6.804983 12.159983 0.8959    
## 3-1 -1.1625 -10.644983  8.319983 0.9967    
## 4-1 -0.2650  -9.747483  9.217483 1.0000    
## 5-1 -0.5350 -10.017483  8.947483 0.9999    
## 6-1  0.0950  -9.387483  9.577483 1.0000    
## 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1