Análise de dados de experimento com nematoides

Autor

Prof. Dr. Walmes Zeviani

Código
# message: false
#-----------------------------------------------------------------------
# Pacotes.

library(emmeans)
library(car)
library(tidyverse)

#-----------------------------------------------------------------------
# Importação dos dados.

# Guias da planilha.
file_xlsx <- "./Planilha Walmes 2023-09-07.xlsx"
readxl::excel_sheets(file_xlsx)
[1] "75 das exp 1 4 subamos" "75 das exp 2 4 subamos" "75 das exp 3 4 subamos"
[4] "produção exp 1"         "produção exp 3"        
Código
# Lista para armazenar as tabelas processadas para análise conjunta.
tb_nema <- list()
tb_prod <- list()

1 Nematoides

1.1 Experimento 1

Código
#=======================================================================
# Experimento 1 · Nematoides. ------------------------------------------

#-----------------------------------------------------------------------
# Importação dos dados.

tb <- readxl::read_excel(file_xlsx, sheet = 1) |>
    drop_na(trat)
str(tb)
tibble [112 × 6] (S3: tbl_df/tbl/data.frame)
 $ trat : chr [1:112] "T01" "T01" "T01" "T01" ...
 $ bloco: num [1:112] 1 1 1 1 2 2 2 2 3 3 ...
 $ mfr  : num [1:112] 5 5 5 5 5 5 5 5 5 5 ...
 $ cont : num [1:112] 120 120 63 90 120 60 120 120 99 120 ...
 $ vol  : num [1:112] 5 5 5 5 5 5 5 5 5 5 ...
 $ pb   : num [1:112] 600 600 315 450 600 300 600 600 495 600 ...
Código
# Converte para fator.
tb <- tb |>
    mutate(trat =  factor(trat),
           bloco = factor(bloco, labels = c("I", "II", "III", "IV")))

# Frequência das combinações experimentais.
xtabs(~trat + bloco, data = tb)
     bloco
trat  I II III IV
  T01 4  4   4  4
  T02 4  4   4  4
  T03 4  4   4  4
  T04 4  4   4  4
  T05 4  4   4  4
  T06 4  4   4  4
  T07 4  4   4  4
Código
# Tomar o valor médio por UE.
tb_m <- tb |>
    group_by(bloco, trat) |>
    summarise(tot_cont = sum(cont),
              tot_vol = sum(vol),
              tot_mfr = sum(mfr),
              n = n(),
              .groups = "drop") |>
    mutate(densidade = (tot_cont/n) * (tot_vol/n))
tb_m
# A tibble: 28 × 7
   bloco trat  tot_cont tot_vol tot_mfr     n densidade
   <fct> <fct>    <dbl>   <dbl>   <dbl> <int>     <dbl>
 1 I     T01        393      20      20     4      491.
 2 I     T02        220      20      20     4      275 
 3 I     T03        450      20      20     4      562.
 4 I     T04        382      20      20     4      478.
 5 I     T05        536      20      20     4      670 
 6 I     T06        360      20      20     4      450 
 7 I     T07        210      20      20     4      262.
 8 II    T01        420      20      20     4      525 
 9 II    T02        192      20      20     4      240 
10 II    T03        482      20      20     4      602.
# … with 18 more rows
Código
# Análise exploratória.
ggplot(data = tb_m,
       mapping = aes(x = trat,
                     y = densidade,
                     color = bloco,
                     group = bloco)) +
    geom_point() +
    geom_line()

Código
# DANGER: Efeito de bloco não parece ser aditivo.

#-----------------------------------------------------------------------
# Análise experimento.

tb_nema[["1"]] <- tb_m

m0 <- lm(densidade + 1 ~ bloco + trat, data = tb_m)

# Exame dos pressupostos no nível mais baixo.
par(mfrow = c(2, 2))
plot(m0, which = 1:3)
MASS::boxcox(m0)
abline(v = 0.5, col = "red")

Código
layout(1)

m1 <- update(m0, sqrt(.) ~ .)
anova(m1)
Analysis of Variance Table

Response: sqrt(densidade + 1)
          Df Sum Sq Mean Sq F value  Pr(>F)  
bloco      3  41.05  13.685  0.9513 0.43683  
trat       6 325.07  54.178  3.7662 0.01321 *
Residuals 18 258.94  14.385                  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Código
# Médias ajustadas.
tb_means <-
    emmeans::emmeans(m1, specs = "trat") |>
    multcomp::cld(Letters = letters, reverse = TRUE, sort = TRUE) |>
    as.data.frame() |>
    mutate(trat = reorder(trat, emmean),
           .group = trimws(.group)) |>
    mutate_at(c("emmean", "lower.CL", "upper.CL"), ~(.)^2 - 1)
tb_means
  trat   emmean       SE df  lower.CL upper.CL .group
2  T05 517.5413 1.896405 18 351.96268 714.8675      a
7  T01 513.7520 1.896405 18 348.83762 710.4141      a
4  T03 489.0716 1.896405 18 328.54452 681.3464      a
6  T06 400.0152 1.896405 18 256.31897 575.4592     ab
3  T04 296.4281 1.896405 18 174.87813 449.7258     ab
1  T07 283.5287 1.896405 18 164.99173 433.8133     ab
5  T02 169.3526 1.896405 18  81.22357 289.2294      b
Código
ggplot(data = tb_means,
       mapping = aes(y = trat, x = emmean)) +
    # scale_x_log10() +
    geom_errorbarh(mapping = aes(xmin = lower.CL,
                                 xmax = upper.CL),
                   height = 0) +
    geom_point() +
    geom_text(mapping = aes(label = sprintf("%0.1f %s",
                                            emmean,
                                            .group)),
              vjust = 0, nudge_y = 0.05) +
    labs(x = "Densidade de nematoides",
         y = "Tratamentos")

1.2 Experimento 2

Código
#=======================================================================
# Experimento 2 · Nematoides. ------------------------------------------

#-----------------------------------------------------------------------
# Importação dos dados.

tb <- readxl::read_excel(file_xlsx, sheet = 2) |>
    drop_na(trat)
str(tb)
tibble [112 × 4] (S3: tbl_df/tbl/data.frame)
 $ trat : chr [1:112] "T01" "T01" "T01" "T01" ...
 $ bloco: num [1:112] 1 1 1 1 2 2 2 2 3 3 ...
 $ mfr  : num [1:112] 7 7 8 5 7 6 7 4 6 5 ...
 $ cont : num [1:112] 94.3 15.7 0 0 10 ...
Código
# Converte para fator.
tb <- tb |>
    mutate(trat =  factor(trat),
           bloco = factor(bloco, labels = c("I", "II", "III", "IV")))

# Frequência das combinações experimentais.
xtabs(~trat + bloco, data = tb)
     bloco
trat  I II III IV
  T01 4  4   4  4
  T02 4  4   4  4
  T03 4  4   4  4
  T04 4  4   4  4
  T05 4  4   4  4
  T06 4  4   4  4
  T07 4  4   4  4
Código
# Tomar o valor médio por UE.
tb_m <- tb |>
    group_by(bloco, trat) |>
    summarise(tot_cont = sum(cont),
              tot_vol = 4 * 10,
              tot_mfr = sum(mfr),
              n = n(),
              .groups = "drop") |>
    mutate(densidade = (tot_cont/n) * (tot_vol/n))
tb_m
# A tibble: 28 × 7
   bloco trat  tot_cont tot_vol tot_mfr     n densidade
   <fct> <fct>    <dbl>   <dbl>   <dbl> <int>     <dbl>
 1 I     T01      110        40      27     4     275  
 2 I     T02       58.6      40      24     4     146. 
 3 I     T03       71.5      40      26     4     179. 
 4 I     T04       30.4      40      28     4      76.0
 5 I     T05      134.       40      22     4     336. 
 6 I     T06       51.4      40      22     4     129. 
 7 I     T07       92.5      40      20     4     231. 
 8 II    T01       50.4      40      24     4     126. 
 9 II    T02       25        40      21     4      62.5
10 II    T03      194.       40      25     4     485. 
# … with 18 more rows
Código
# Análise exploratória.
ggplot(data = tb_m,
       mapping = aes(x = trat,
                     y = densidade,
                     color = bloco,
                     group = bloco)) +
    geom_point() +
    geom_line()

Código
# DANGER: Efeito de bloco não parece ser aditivo.

#-----------------------------------------------------------------------
# Análise experimento.

tb_nema[["2"]] <- tb_m

m0 <- lm(densidade + 1 ~ bloco + trat, data = tb_m)

# Exame dos pressupostos no nível mais baixo.
par(mfrow = c(2, 2))
plot(m0, which = 1:3)
MASS::boxcox(m0)
abline(v = 0.5, col = "red")

Código
layout(1)

m1 <- update(m0, sqrt(.) ~ .)
anova(m1)
Analysis of Variance Table

Response: sqrt(densidade + 1)
          Df Sum Sq Mean Sq F value  Pr(>F)  
bloco      3  66.75  22.250  0.8077 0.50595  
trat       6 490.52  81.753  2.9678 0.03404 *
Residuals 18 495.84  27.546                  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Código
# Médias ajustadas.
tb_means <-
    emmeans::emmeans(m1, specs = "trat") |>
    multcomp::cld(Letters = letters, reverse = TRUE, sort = TRUE) |>
    as.data.frame() |>
    mutate(trat = reorder(trat, emmean),
           .group = trimws(.group)) |>
    mutate_at(c("emmean", "lower.CL", "upper.CL"), ~(.)^2 - 1)
tb_means
  trat   emmean       SE df  lower.CL upper.CL .group
2  T07 611.3314 2.624237 18 368.87034 914.5858      a
3  T01 313.9630 2.624237 18 148.66779 540.0515     ab
6  T05 284.8741 2.624237 18 128.83448 501.7070     ab
4  T04 235.6136 2.624237 18  96.39580 435.6247     ab
5  T06 210.6616 2.624237 18  80.63626 401.4804     ab
1  T03 172.1027 2.624237 18  57.42360 347.5752     ab
7  T02 106.3426 2.624237 18  22.49641 250.9821      b
Código
ggplot(data = tb_means,
       mapping = aes(y = trat, x = emmean)) +
    # scale_x_log10() +
    geom_errorbarh(mapping = aes(xmin = lower.CL,
                                 xmax = upper.CL),
                   height = 0) +
    geom_point() +
    geom_text(mapping = aes(label = sprintf("%0.1f %s",
                                            emmean,
                                            .group)),
              vjust = 0, nudge_y = 0.05) +
    labs(x = "Densidade de nematoides",
         y = "Tratamentos")

1.3 Experimento 3

Código
#=======================================================================
# Experimento 3 · Nematoides. ------------------------------------------

#-----------------------------------------------------------------------
# Importação dos dados.

tb <- readxl::read_excel(file_xlsx, sheet = 3) |>
    drop_na(trat)
str(tb)
tibble [112 × 8] (S3: tbl_df/tbl/data.frame)
 $ trat  : chr [1:112] "T01" "T01" "T01" "T01" ...
 $ bloco : chr [1:112] "A" "A" "A" "A" ...
 $ rep   : num [1:112] 1 2 3 4 1 2 3 4 1 2 ...
 $ mfr   : num [1:112] 7.57 5.58 6.75 5.59 5.08 4.06 4.62 5.11 9.86 7.47 ...
 $ cont  : num [1:112] 4 60 102 70 10 2 6 0 12 10 ...
 $ vol   : num [1:112] 74 48 48 54 64 78 50 40 48 50 ...
 $ pb    : num [1:112] 296 2880 4896 3780 640 ...
 $ nema.g: num [1:112] 39.1 516.1 725.3 676.2 126 ...
Código
# Converte para fator.
tb <- tb |>
    mutate(trat =  factor(trat),
           bloco = factor(bloco, labels = c("I", "II", "III", "IV")))

# Frequência das combinações experimentais.
xtabs(~trat + bloco, data = tb)
     bloco
trat  I II III IV
  T01 4  4   4  4
  T02 4  4   4  4
  T03 4  4   4  4
  T04 4  4   4  4
  T05 4  4   4  4
  T06 4  4   4  4
  T07 4  4   4  4
Código
# Tomar o valor médio por UE.
tb_m <- tb |>
    group_by(bloco, trat) |>
    summarise(tot_cont = sum(cont),
              tot_vol = sum(vol),
              tot_mfr = sum(mfr),
              n = n(),
              .groups = "drop") |>
    mutate(densidade = (tot_cont/n) * (tot_vol/n))
tb_m
# A tibble: 28 × 7
   bloco trat  tot_cont tot_vol tot_mfr     n densidade
   <fct> <fct>    <dbl>   <dbl>   <dbl> <int>     <dbl>
 1 I     T01        236     224    25.5     4    3304  
 2 I     T02        154     244    27.8     4    2348. 
 3 I     T03        110     270    23.0     4    1856. 
 4 I     T04         32     186    24.2     4     372  
 5 I     T05          0     191    17.0     4       0  
 6 I     T06         20     247    18.5     4     309. 
 7 I     T07         48     166    14.8     4     498  
 8 II    T01         18     232    18.9     4     261  
 9 II    T02        104     234    29.9     4    1521  
10 II    T03          6     215    21.3     4      80.6
# … with 18 more rows
Código
# Análise exploratória.
ggplot(data = tb_m,
       mapping = aes(x = trat,
                     y = densidade,
                     color = bloco,
                     group = bloco)) +
    geom_point() +
    geom_line()

Código
# DANGER: Efeito de bloco não parece ser aditivo.

#-----------------------------------------------------------------------
# Análise experimento.

tb_nema[["3"]] <- tb_m

m0 <- lm(densidade + 1 ~ bloco + trat, data = tb_m)

# Exame dos pressupostos no nível mais baixo.
par(mfrow = c(2, 2))
plot(m0, which = 1:3)
MASS::boxcox(m0)
abline(v = c(0, 1/3, 1/2), col = "red")

Código
layout(1)

# m1 <- update(m0, log(.) ~ .)
m1 <- update(m0, (.)^(1/3) ~ .)
anova(m1)
Analysis of Variance Table

Response: (densidade + 1)^(1/3)
          Df  Sum Sq Mean Sq F value    Pr(>F)    
bloco      3  28.268   9.423  1.7716 0.1885920    
trat       6 232.690  38.782  7.2914 0.0004554 ***
Residuals 18  95.739   5.319                      
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Código
# Médias ajustadas.
tb_means <-
    emmeans::emmeans(m1, specs = "trat") |>
    multcomp::cld(Letters = letters, reverse = TRUE, sort = TRUE) |>
    as.data.frame() |>
    mutate(trat = reorder(trat, emmean),
           .group = trimws(.group)) |>
    # mutate_at(c("emmean", "lower.CL", "upper.CL"), ~exp(.) - 1)
    mutate_at(c("emmean", "lower.CL", "upper.CL"), ~(.)^3 - 1)
tb_means
  trat      emmean       SE df   lower.CL   upper.CL .group
5  T02 1825.044585 1.153129 18 940.238006 3140.27578      a
4  T01  838.245320 1.153129 18 343.461495 1665.19600     ab
3  T07  709.358336 1.153129 18 273.623554 1459.30249     ab
6  T06  553.448319 1.153129 18 193.367003 1202.82868     ab
7  T03  356.896565 1.153129 18 101.324032  862.49163    abc
1  T04  256.774277 1.153129 18  60.237820  677.42689     bc
2  T05    8.883265 1.153129 18  -1.021165   94.35956      c
Código
ggplot(data = tb_means,
       mapping = aes(y = trat, x = emmean)) +
    # scale_x_log10() +
    geom_errorbarh(mapping = aes(xmin = lower.CL,
                                 xmax = upper.CL),
                   height = 0) +
    geom_point() +
    geom_text(mapping = aes(label = sprintf("%0.1f %s",
                                            emmean,
                                            .group)),
              vjust = 0, nudge_y = 0.05) +
    labs(x = "Densidade de nematoides",
         y = "Tratamentos")

1.4 Análise conjunta

Código
#=======================================================================
# Análise conjunta -----------------------------------------------------

tb <- bind_rows(tb_nema, .id = "experimento")

# Converte para fator.
tb <- tb |>
    mutate(experimento =  factor(experimento),
           blocoin = interaction(experimento, bloco, sep = "_"))

# Frequência das combinações experimentais.
xtabs(~experimento + trat + bloco, data = tb) |>
    ftable()
                 bloco I II III IV
experimento trat                  
1           T01        1  1   1  1
            T02        1  1   1  1
            T03        1  1   1  1
            T04        1  1   1  1
            T05        1  1   1  1
            T06        1  1   1  1
            T07        1  1   1  1
2           T01        1  1   1  1
            T02        1  1   1  1
            T03        1  1   1  1
            T04        1  1   1  1
            T05        1  1   1  1
            T06        1  1   1  1
            T07        1  1   1  1
3           T01        1  1   1  1
            T02        1  1   1  1
            T03        1  1   1  1
            T04        1  1   1  1
            T05        1  1   1  1
            T06        1  1   1  1
            T07        1  1   1  1
Código
# Análise exploratória.
ggplot(data = tb,
       mapping = aes(x = trat,
                     y = densidade,
                     color = bloco,
                     group = bloco)) +
    facet_wrap(facets = ~experimento) +
    geom_point() +
    geom_line()

Código
#-----------------------------------------------------------------------
# Análise experimento.

# Apenas para avaliar os pressupostos.
m0 <- lm(densidade + 1 ~ experimento + blocoin + trat,
         data = tb)

# Exame dos pressupostos no nível mais baixo.
par(mfrow = c(2, 2))
plot(m0, which = 1:3)
MASS::boxcox(m0)
abline(v = c(0, 1/3, 1/2), col = "red")

Código
layout(1)

# Apenas para avaliar os pressupostos.
m1 <- aov((densidade + 1)^(1/3) ~ experimento + blocoin + 
              experimento * trat + Error(experimento:blocoin),
         data = tb)
summary(m1)

Error: experimento:blocoin
            Df Sum Sq Mean Sq
experimento  2  32.36  16.182
blocoin      9  35.95   3.994

Error: Within
                 Df Sum Sq Mean Sq F value  Pr(>F)    
trat              6  57.55   9.592   3.301 0.00769 ** 
experimento:trat 12 231.26  19.272   6.632 4.1e-07 ***
Residuals        54 156.92   2.906                    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Como ocorre interação entre experimento e tratamentos, isso significa que as diferenças entre tratamentos são dependentes do experimento. O estudo do efeito de tratamentos dentro de cada experimento individualmente já foi realizado nas seções anteriores.

2 Produção

2.1 Experimento 1

Código
#=======================================================================
# Experimento 1 · Produção. --------------------------------------------

#-----------------------------------------------------------------------
# Importação dos dados.

tb <- readxl::read_excel(file_xlsx, sheet = 4) |>
    drop_na(trat)
str(tb)
tibble [112 × 4] (S3: tbl_df/tbl/data.frame)
 $ trat : chr [1:112] "T01" "T01" "T01" "T01" ...
 $ bloco: num [1:112] 1 2 3 4 1 2 3 4 1 2 ...
 $ rep  : num [1:112] 1 1 1 1 1 1 1 1 1 1 ...
 $ produ: num [1:112] 600 615 515 618 680 698 870 659 704 743 ...
Código
# Converte para fator.
tb <- tb |>
    mutate(trat =  factor(trat),
           bloco = factor(bloco, labels = c("I", "II", "III", "IV")))

# Frequência das combinações experimentais.
xtabs(~trat + bloco, data = tb)
     bloco
trat  I II III IV
  T01 4  4   4  4
  T02 4  4   4  4
  T03 4  4   4  4
  T04 4  4   4  4
  T05 4  4   4  4
  T06 4  4   4  4
  T07 4  4   4  4
Código
# Tomar o valor médio por UE.
tb_m <- tb |>
    group_by(bloco, trat) |>
    summarise_at("produ", mean, .groups = "drop")
tb_m
# A tibble: 28 × 3
# Groups:   bloco [4]
   bloco trat  produ
   <fct> <fct> <dbl>
 1 I     T01    625 
 2 I     T02    729 
 3 I     T03    706.
 4 I     T04    607 
 5 I     T05    700.
 6 I     T06    712.
 7 I     T07    690.
 8 II    T01    652.
 9 II    T02    684.
10 II    T03    654 
# … with 18 more rows
Código
# Análise exploratória.
ggplot(data = tb_m,
       mapping = aes(x = trat,
                     y = produ,
                     color = bloco,
                     group = bloco)) +
    geom_point() +
    geom_line()

Código
# DANGER: Efeito de bloco não parece ser aditivo.

#-----------------------------------------------------------------------
# Análise experimento.

tb_prod[["1"]] <- tb_m

m0 <- lm(produ ~ bloco + trat, data = tb_m)

# Exame dos pressupostos no nível mais baixo.
par(mfrow = c(2, 2))
plot(m0, which = 1:3)
# MASS::boxcox(m0)
# abline(v = c(0, 1/3, 1/2), col = "red")
layout(1)

Código
m1 <- m0

# Médias ajustadas.
tb_means <-
    emmeans::emmeans(m1, specs = "trat") |>
    multcomp::cld(Letters = letters, reverse = TRUE, sort = TRUE) |>
    as.data.frame() |>
    # mutate_at(c("emmean", "lower.CL", "upper.CL"), ~(.)^3 - 1) |>
    mutate(trat = reorder(trat, emmean),
           .group = trimws(.group))
tb_means
  trat   emmean       SE df lower.CL upper.CL .group
7  T06 733.5000 21.28006 18 688.7923 778.2077      a
4  T02 711.6250 21.28006 18 666.9173 756.3327      a
5  T03 690.3750 21.28006 18 645.6673 735.0827      a
1  T01 681.6250 21.28006 18 636.9173 726.3327      a
3  T05 668.3125 21.28006 18 623.6048 713.0202      a
2  T04 668.2500 21.28006 18 623.5423 712.9577      a
6  T07 665.6250 21.28006 18 620.9173 710.3327      a
Código
ggplot(data = tb_means,
       mapping = aes(y = trat, x = emmean)) +
    # scale_x_log10() +
    geom_errorbarh(mapping = aes(xmin = lower.CL,
                                 xmax = upper.CL),
                   height = 0) +
    geom_point() +
    geom_text(mapping = aes(label = sprintf("%0.1f %s",
                                            emmean,
                                            .group)),
              vjust = 0, nudge_y = 0.05) +
    labs(x = "Produção (g)",
         y = "Tratamentos")

2.2 Experimento 3

Código
#=======================================================================
# Experimento 3 · Produção. --------------------------------------------

#-----------------------------------------------------------------------
# Importação dos dados.

tb <- readxl::read_excel(file_xlsx, sheet = 5) |>
    drop_na(trat)
str(tb)
tibble [28 × 3] (S3: tbl_df/tbl/data.frame)
 $ trat : chr [1:28] "T01" "T01" "T01" "T01" ...
 $ bloco: chr [1:28] "A" "B" "C" "D" ...
 $ produ: num [1:28] 305 352 285 364 425 ...
Código
# Converte para fator.
tb <- tb |>
    mutate(trat =  factor(trat),
           bloco = factor(bloco, labels = c("I", "II", "III", "IV")))

# Frequência das combinações experimentais.
xtabs(~trat + bloco, data = tb)
     bloco
trat  I II III IV
  T01 1  1   1  1
  T02 1  1   1  1
  T03 1  1   1  1
  T04 1  1   1  1
  T05 1  1   1  1
  T06 1  1   1  1
  T07 1  1   1  1
Código
# Análise exploratória.
ggplot(data = tb,
       mapping = aes(x = trat,
                     y = produ,
                     color = bloco,
                     group = bloco)) +
    geom_point() +
    geom_line()

Código
# DANGER: Efeito de bloco não parece ser aditivo.

#-----------------------------------------------------------------------
# Análise experimento.

tb_prod[["3"]] <- tb

m0 <- lm(produ ~ bloco + trat, data = tb)

# Exame dos pressupostos no nível mais baixo.
par(mfrow = c(2, 2))
plot(m0, which = 1:3)
# MASS::boxcox(m0)
# abline(v = c(0, 1/3, 1/2), col = "red")
layout(1)

Código
m1 <- m0

# Médias ajustadas.
tb_means <-
    emmeans::emmeans(m1, specs = "trat") |>
    multcomp::cld(Letters = letters, reverse = TRUE, sort = TRUE) |>
    as.data.frame() |>
    # mutate_at(c("emmean", "lower.CL", "upper.CL"), ~(.)^3 - 1) |>
    mutate(trat = reorder(trat, emmean),
           .group = trimws(.group))
tb_means
  trat   emmean       SE df lower.CL upper.CL .group
1  T04 526.1250 14.49487 18 495.6724 556.5776      a
2  T06 523.9650 14.49487 18 493.5124 554.4176      a
3  T07 517.0550 14.49487 18 486.6024 547.5076      a
5  T05 507.8575 14.49487 18 477.4049 538.3101      a
7  T03 468.7775 14.49487 18 438.3249 499.2301     ab
6  T02 434.7500 14.49487 18 404.2974 465.2026      b
4  T01 326.5675 14.49487 18 296.1149 357.0201      c
Código
ggplot(data = tb_means,
       mapping = aes(y = trat, x = emmean)) +
    # scale_x_log10() +
    geom_errorbarh(mapping = aes(xmin = lower.CL,
                                 xmax = upper.CL),
                   height = 0) +
    geom_point() +
    geom_text(mapping = aes(label = sprintf("%0.1f %s",
                                            emmean,
                                            .group)),
              vjust = 0, nudge_y = 0.05) +
    labs(x = "Produção (g)",
         y = "Tratamentos")

Código
#-----------------------------------------------------------------------

2.3 Análise conjunta

Código
#=======================================================================
# Análise conjunta -----------------------------------------------------

tb <- bind_rows(tb_prod, .id = "experimento")

# Converte para fator.
tb <- tb |>
    mutate(experimento =  factor(experimento),
           blocoin = interaction(experimento, bloco, sep = "_"))

# Frequência das combinações experimentais.
xtabs(~experimento + trat + bloco, data = tb) |>
    ftable()
                 bloco I II III IV
experimento trat                  
1           T01        1  1   1  1
            T02        1  1   1  1
            T03        1  1   1  1
            T04        1  1   1  1
            T05        1  1   1  1
            T06        1  1   1  1
            T07        1  1   1  1
3           T01        1  1   1  1
            T02        1  1   1  1
            T03        1  1   1  1
            T04        1  1   1  1
            T05        1  1   1  1
            T06        1  1   1  1
            T07        1  1   1  1
Código
# Análise exploratória.
ggplot(data = tb,
       mapping = aes(x = trat,
                     y = produ,
                     color = bloco,
                     group = bloco)) +
    facet_wrap(facets = ~experimento) +
    geom_point() +
    geom_line()

Código
#-----------------------------------------------------------------------
# Análise experimento.

# Apenas para avaliar os pressupostos.
m0 <- lm(produ ~ experimento + blocoin + trat,
         data = tb)

# Exame dos pressupostos no nível mais baixo.
par(mfrow = c(2, 2))
plot(m0, which = 1:3)
layout(1)

Código
# Apenas para avaliar os pressupostos.
m1 <- aov(produ ~ experimento + blocoin + 
              experimento * trat + Error(experimento:blocoin),
         data = tb)
summary(m1)

Error: experimento:blocoin
            Df Sum Sq Mean Sq
experimento  1 655099  655099
blocoin      6  11582    1930

Error: Within
                 Df Sum Sq Mean Sq F value   Pr(>F)    
trat              6  69372   11562   8.720 6.91e-06 ***
experimento:trat  6  72409   12068   9.102 4.50e-06 ***
Residuals        36  47732    1326                     
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Como ocorre interação entre experimento e tratamentos, isso significa que as diferenças entre tratamentos são dependentes do experimento. O estudo do efeito de tratamentos dentro de cada experimento individualmente já foi realizado nas seções anteriores.