Capítulo 18 Blocos aumentados de Federer

  • RamalhoEg11.13: blocos incompletos com 4 populações comuns e 25 populações regulares.
  • RamalhoTb11.17: blocos incompletos com testemunhas comuns a todos os blocos.
  • ZimmermannTb8.5: TODO

18.1 RamalhoEg11.13

Os dados em RamalhoEg11.13 referem-se a produção (kg/parcela) de populações de milho avaliadas no delieneamento de blocos aumentados.

# Importa os dados.
da <- as_tibble(labestData::RamalhoEg11.13)
str(da)
## Classes 'tbl_df', 'tbl' and 'data.frame':    45 obs. of  3 variables:
##  $ pop : Factor w/ 29 levels "I","II","III",..: 1 2 3 4 5 6 7 8 9 10 ...
##  $ bloc: Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ prod: num  7.5 8.2 9.4 6.8 8.1 4.2 7.4 9.3 8.9 7.5 ...
with(da, table(pop, bloc)) %>%
    addmargins() %>%
    print.table(zero.print = ".")
##      bloc
## pop    1  2  3  4  5 Sum
##   I    1  1  1  1  1   5
##   II   1  1  1  1  1   5
##   III  1  1  1  1  1   5
##   IV   1  1  1  1  1   5
##   1    1  .  .  .  .   1
##   2    1  .  .  .  .   1
##   3    1  .  .  .  .   1
##   4    1  .  .  .  .   1
##   5    1  .  .  .  .   1
##   6    1  .  .  .  .   1
##   7    .  1  .  .  .   1
##   8    .  1  .  .  .   1
##   9    .  1  .  .  .   1
##   10   .  1  .  .  .   1
##   11   .  1  .  .  .   1
##   12   .  1  .  .  .   1
##   13   .  .  1  .  .   1
##   14   .  .  1  .  .   1
##   15   .  .  1  .  .   1
##   16   .  .  1  .  .   1
##   17   .  .  1  .  .   1
##   18   .  .  .  1  .   1
##   19   .  .  .  1  .   1
##   20   .  .  .  1  .   1
##   21   .  .  .  1  .   1
##   22   .  .  .  .  1   1
##   23   .  .  .  .  1   1
##   24   .  .  .  .  1   1
##   25   .  .  .  .  1   1
##   Sum 10 10  9  8  8  45
library(igraph)

edg <- by(data = as.integer(da$pop),
          INDICES = da$bloc,
          FUN = combn,
          m = 2) %>%
    flatten_int()

p <- 4
pal <- RColorBrewer::brewer.pal(n = nlevels(da$bloc) + 1,
                                name = "Set1")
clr <- rep(head(pal, n = -1),
           tapply(da$pop, da$bloc, length) - p)
clr <- append(clr, rep(tail(pal, n = 1), p),
              after = 0)

ghp <- graph(edg, directed = FALSE)
plot(ghp,
     vertex.color = clr,
     layout = layout_nicely,
     edge.curved = FALSE)

#

18.2 RamalhoTb11.17

da <- as_tibble(labestData::RamalhoTb11.17)
str(da)
## Classes 'tbl_df', 'tbl' and 'data.frame':    48 obs. of  4 variables:
##  $ exp : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 1 1 1 1 1 ...
##  $ linh: Factor w/ 18 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 1 2 ...
##  $ bloc: Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 2 2 ...
##  $ prod: num  5.7 6.1 7.2 5.2 4.3 5.5 5.9 4.5 5.7 6.1 ...
with(da, table(bloc, linh, exp)) %>%
    addmargins(margin = 1:2) %>%
    print.table(zero.print = ".")
## , , exp = 1
## 
##      linh
## bloc   1  2  3  4  5  6  7  8 9 10 11 12 13 14 15 16 17 18 Sum
##   1    1  1  1  1  1  1  1  1 .  .  .  .  .  .  .  .  .  .   8
##   2    1  1  1  1  1  1  1  1 .  .  .  .  .  .  .  .  .  .   8
##   Sum  2  2  2  2  2  2  2  2 .  .  .  .  .  .  .  .  .  .  16
## 
## , , exp = 2
## 
##      linh
## bloc   1  2  3 4 5 6 7 8  9 10 11 12 13 14 15 16 17 18 Sum
##   1    1  1  1 . . . . .  1  1  1  1  1  .  .  .  .  .   8
##   2    1  1  1 . . . . .  1  1  1  1  1  .  .  .  .  .   8
##   Sum  2  2  2 . . . . .  2  2  2  2  2  .  .  .  .  .  16
## 
## , , exp = 3
## 
##      linh
## bloc   1  2  3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Sum
##   1    1  1  1 . . . . . .  .  .  .  .  1  1  1  1  1   8
##   2    1  1  1 . . . . . .  .  .  .  .  1  1  1  1  1   8
##   Sum  2  2  2 . . . . . .  .  .  .  .  2  2  2  2  2  16
library(igraph)

# Todos os possíveis pares.
pares <- apply(combn(sort(as.character(levels(da$linh))), m = 2),
               MARGIN = 2,
               FUN = paste0,
               collapse = "_") %>%
    tibble(name = ., value = 0)
head(pares)

da$cond <- interaction(da$exp, da$bloc, drop = TRUE)

# Quantas vezes cada par ocorre junto.
by(data = as.character(da$linh),
   INDICES = da$cond,
   FUN = function(x) {
       apply(combn(sort(x), m = 2),
             MARGIN = 2,
             FUN = paste0,
             collapse = "_")
   }) %>%
    flatten_chr() %>%
    table() %>%
    c() %>%
    enframe() %>%
    bind_rows(pares) %>%
    distinct(name, .keep_all = TRUE) %>%
    split(x = .$name, f = .$value)

edg <- by(data = as.integer(da$linh),
          INDICES = da$cond,
          FUN = combn,
          m = 2) %>%
    flatten_int()

p <- 3
pal <- RColorBrewer::brewer.pal(n = nlevels(da$cond) + 1,
                                name = "Set1")
clr <- rep(head(pal, n = -1),
           tapply(da$cond, da$cond, length) - p)
clr <- append(clr, rep(tail(pal, n = 1), p),
              after = 0)

ghp <- graph(edg, directed = FALSE)
plot(ghp,
     vertex.color = clr,
     layout = layout_nicely,
     edge.curved = FALSE)
# Modelo de efeitos fixos.
m0 <- lm(terms(prod ~ exp/bloc + linh, keep.order = TRUE),
         data = da)

# Quado de anova com hipóteses marginais.
Anova(m0)
## Anova Table (Type II tests)
## 
## Response: prod
##            Sum Sq Df F value    Pr(>F)    
## exp        3.3078  2  4.3208 0.0244504 *  
## exp:bloc  10.3162  3  8.9838 0.0003271 ***
## linh      20.4282 17  3.1394 0.0047220 ** 
## Residuals  9.5693 25                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Médias marginais ajustadas.
emm <- emmeans(m0, specs = ~linh)
## NOTE: A nesting structure was detected in the fitted model:
##     bloc %in% exp
emm
##  linh emmean    SE df lower.CL upper.CL
##  1      5.63 0.253 25     5.11     6.15
##  2      6.25 0.253 25     5.73     6.77
##  3      7.15 0.253 25     6.63     7.67
##  4      5.24 0.484 25     4.25     6.24
##  5      4.99 0.484 25     4.00     5.99
##  6      5.79 0.484 25     4.80     6.79
##  7      6.19 0.484 25     5.20     7.19
##  8      6.14 0.484 25     5.15     7.14
##  9      5.53 0.484 25     4.53     6.52
##  10     6.93 0.484 25     5.93     7.92
##  11     6.23 0.484 25     5.23     7.22
##  12     6.23 0.484 25     5.23     7.22
##  13     5.93 0.484 25     4.93     6.92
##  14     7.28 0.484 25     6.28     8.27
##  15     7.58 0.484 25     6.58     8.57
##  16     8.38 0.484 25     7.38     9.37
##  17     7.23 0.484 25     6.23     8.22
##  18     7.13 0.484 25     6.13     8.12
## 
## Results are averaged over the levels of: bloc, exp 
## Confidence level used: 0.95
# Extração da matriz de funções lineares.
L <- attr(emm, "linfct")
grid <- attr(emm, "grid")
rownames(L) <- grid[[1]]

# Entenda como são obtidas as médias marginais.
MASS::fractions(t(L))
##             1   2   3   4   5   6   7   8   9   10  11  12  13  14 
## (Intercept)   1   1   1   1   1   1   1   1   1   1   1   1   1   1
## exp2        1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3
## exp3        1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3 1/3
## exp1:bloc2  1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6
## exp2:bloc2  1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6
## exp3:bloc2  1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6 1/6
## linh2         0   1   0   0   0   0   0   0   0   0   0   0   0   0
## linh3         0   0   1   0   0   0   0   0   0   0   0   0   0   0
## linh4         0   0   0   1   0   0   0   0   0   0   0   0   0   0
## linh5         0   0   0   0   1   0   0   0   0   0   0   0   0   0
## linh6         0   0   0   0   0   1   0   0   0   0   0   0   0   0
## linh7         0   0   0   0   0   0   1   0   0   0   0   0   0   0
## linh8         0   0   0   0   0   0   0   1   0   0   0   0   0   0
## linh9         0   0   0   0   0   0   0   0   1   0   0   0   0   0
## linh10        0   0   0   0   0   0   0   0   0   1   0   0   0   0
## linh11        0   0   0   0   0   0   0   0   0   0   1   0   0   0
## linh12        0   0   0   0   0   0   0   0   0   0   0   1   0   0
## linh13        0   0   0   0   0   0   0   0   0   0   0   0   1   0
## linh14        0   0   0   0   0   0   0   0   0   0   0   0   0   1
## linh15        0   0   0   0   0   0   0   0   0   0   0   0   0   0
## linh16        0   0   0   0   0   0   0   0   0   0   0   0   0   0
## linh17        0   0   0   0   0   0   0   0   0   0   0   0   0   0
## linh18        0   0   0   0   0   0   0   0   0   0   0   0   0   0
##             15  16  17  18 
## (Intercept)   1   1   1   1
## exp2        1/3 1/3 1/3 1/3
## exp3        1/3 1/3 1/3 1/3
## exp1:bloc2  1/6 1/6 1/6 1/6
## exp2:bloc2  1/6 1/6 1/6 1/6
## exp3:bloc2  1/6 1/6 1/6 1/6
## linh2         0   0   0   0
## linh3         0   0   0   0
## linh4         0   0   0   0
## linh5         0   0   0   0
## linh6         0   0   0   0
## linh7         0   0   0   0
## linh8         0   0   0   0
## linh9         0   0   0   0
## linh10        0   0   0   0
## linh11        0   0   0   0
## linh12        0   0   0   0
## linh13        0   0   0   0
## linh14        0   0   0   0
## linh15        1   0   0   0
## linh16        0   1   0   0
## linh17        0   0   1   0
## linh18        0   0   0   1
# Contrastes par a par.
ctr <- summary(glht(m0, linfct = all_pairwise(L)),
               test = adjusted(type = "fdr"))

# Erros padrões de vários tamanhos conforme estrutura de associação.
v <- c("coefficients", "sigma", "tstat", "pvalues")
ctr$test[v] %>%
    as.data.frame() %>%
    split(., round(.$sigma, 4)) %>%
    map(head, n = 5)
## $`0.3572`
##      coefficients     sigma     tstat    pvalues
## 1vs2   -0.6166667 0.3571985 -1.726398 0.22397225
## 1vs3   -1.5166667 0.3571985 -4.246006 0.01005365
## 2vs3   -0.9000000 0.3571985 -2.519608 0.09439470
## 
## $`0.5456`
##      coefficients     sigma      tstat   pvalues
## 1vs4    0.3888889 0.5456297  0.7127341 0.6477138
## 1vs5    0.6388889 0.5456297  1.1709204 0.4112625
## 1vs6   -0.1611111 0.5456297 -0.2952756 0.8794324
## 1vs7   -0.5611111 0.5456297 -1.0283735 0.4671447
## 1vs8   -0.5111111 0.5456297 -0.9367363 0.5191158
## 
## $`0.6187`
##      coefficients     sigma      tstat   pvalues
## 4vs5         0.25 0.6186859  0.4040823 0.8178837
## 4vs6        -0.55 0.6186859 -0.8889810 0.5418575
## 4vs7        -0.95 0.6186859 -1.5355126 0.2837080
## 4vs8        -0.90 0.6186859 -1.4546962 0.3063777
## 5vs6        -0.80 0.6186859 -1.2930633 0.3532791
## 
## $`0.7144`
##       coefficients     sigma      tstat   pvalues
## 4vs9    -0.2833333 0.7143969 -0.3966049 0.8179899
## 4vs10   -1.6833333 0.7143969 -2.3562998 0.1100068
## 4vs11   -0.9833333 0.7143969 -1.3764524 0.3255944
## 4vs12   -0.9833333 0.7143969 -1.3764524 0.3255944
## 4vs13   -0.6833333 0.7143969 -0.9565177 0.5119170
# Comparações múltiplas a 10%.
results_m0 <- wzRfun::apmc(X = L,
                           model = m0,
                           focus = "linh",
                           test = "fdr")
results_m0
##    linh      fit      lwr      upr  cld
## 1     1 5.633333 5.113140 6.153526   df
## 2     2 6.250000 5.729807 6.770193  bcf
## 3     3 7.150000 6.629807 7.670193   ab
## 4     4 5.244444 4.248351 6.240538   ef
## 5     5 4.994444 3.998351 5.990538    f
## 6     6 5.794444 4.798351 6.790538  bcf
## 7     7 6.194444 5.198351 7.190538  bcf
## 8     8 6.144444 5.148351 7.140538  bcf
## 9     9 5.527778 4.531684 6.523872   cf
## 10   10 6.927778 5.931684 7.923872  acf
## 11   11 6.227778 5.231684 7.223872  bcf
## 12   12 6.227778 5.231684 7.223872  bcf
## 13   13 5.927778 4.931684 6.923872  bcf
## 14   14 7.277778 6.281684 8.273872  ace
## 15   15 7.577778 6.581684 8.573872   ac
## 16   16 8.377778 7.381684 9.373872    a
## 17   17 7.227778 6.231684 8.223872  ace
## 18   18 7.127778 6.131684 8.123872 acde
# Gráfico de segmentos para as estimativas intervalares.
ggplot(data = results_m0,
       mapping = aes(x = fit, y = reorder(linh, fit))) +
    geom_point() +
    geom_errorbarh(mapping = aes(xmin = lwr, xmax = upr),
                   height = 0) +
    geom_label(mapping = aes(label = sprintf("%0.2f%s", fit, cld)),
               label.padding = unit(0.15, "lines"),
               fill = "black",
               colour = "white",
               size = 3,
               nudge_x = 0.25,
               vjust = 0.5) +
    labs(x = "Produção",
         y = "Linhagens")

# Ajuste do modelo de efeito aleatório de bloc.
mm0 <- lmer(prod ~ exp + (1 | exp:bloc) + linh, data = da)

# Quadro de teste de Wald.
anova(mm0)
## Type III Analysis of Variance Table with Satterthwaite's method
##       Sum Sq Mean Sq NumDF   DenDF F value   Pr(>F)   
## exp   0.8282 0.41412     2  4.1993  1.0819 0.417863   
## linh 20.4282 1.20166    17 24.9999  3.1393 0.004722 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Estimativas dos parâmetros dos termos de efeito.
summary(mm0)
## Linear mixed model fit by REML. t-tests use Satterthwaite's  method
##  [lmerModLmerTest]
## Formula: prod ~ exp + (1 | exp:bloc) + linh
##    Data: da
## 
## REML criterion at convergence: 77.4
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.11931 -0.49619 -0.06273  0.61283  2.11931 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  exp:bloc (Intercept) 0.3820   0.6180  
##  Residual             0.3828   0.6187  
## Number of obs: 48, groups:  exp:bloc, 6
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)   5.6389     0.5453  5.6424  10.342 7.04e-05 ***
## exp2          0.5167     0.7138  4.1993   0.724 0.507470    
## exp3         -0.5333     0.7138  4.1993  -0.747 0.494653    
## linh2         0.6167     0.3572 24.9999   1.726 0.096616 .  
## linh3         1.5167     0.3572 24.9999   4.246 0.000263 ***
## linh4        -0.3889     0.5456 24.9999  -0.713 0.482611    
## linh5        -0.6389     0.5456 24.9999  -1.171 0.252672    
## linh6         0.1611     0.5456 24.9999   0.295 0.770222    
## linh7         0.5611     0.5456 24.9999   1.028 0.313623    
## linh8         0.5111     0.5456 24.9999   0.937 0.357857    
## linh9        -0.1056     0.5456 24.9999  -0.193 0.848165    
## linh10        1.2944     0.5456 24.9999   2.372 0.025681 *  
## linh11        0.5944     0.5456 24.9999   1.089 0.286341    
## linh12        0.5944     0.5456 24.9999   1.089 0.286341    
## linh13        0.2944     0.5456 24.9999   0.540 0.594220    
## linh14        1.6444     0.5456 24.9999   3.014 0.005841 ** 
## linh15        1.9444     0.5456 24.9999   3.564 0.001504 ** 
## linh16        2.7444     0.5456 24.9999   5.030 3.45e-05 ***
## linh17        1.5944     0.5456 24.9999   2.922 0.007273 ** 
## linh18        1.4944     0.5456 24.9999   2.739 0.011199 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation matrix not shown by default, as p = 20 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
# Médias marginais ajustadas.
emm <- emmeans(mm0, specs = ~linh)
emm
##  linh emmean    SE    df lower.CL upper.CL
##  1      5.63 0.357  8.85     4.82     6.44
##  2      6.25 0.357  8.85     5.44     7.06
##  3      7.15 0.357  8.85     6.34     7.96
##  4      5.24 0.546 23.60     4.12     6.37
##  5      4.99 0.546 23.60     3.87     6.12
##  6      5.79 0.546 23.60     4.67     6.92
##  7      6.19 0.546 23.60     5.07     7.32
##  8      6.14 0.546 23.60     5.02     7.27
##  9      5.53 0.546 23.60     4.40     6.65
##  10     6.93 0.546 23.60     5.80     8.05
##  11     6.23 0.546 23.60     5.10     7.35
##  12     6.23 0.546 23.60     5.10     7.35
##  13     5.93 0.546 23.60     4.80     7.05
##  14     7.28 0.546 23.60     6.15     8.40
##  15     7.58 0.546 23.60     6.45     8.70
##  16     8.38 0.546 23.60     7.25     9.50
##  17     7.23 0.546 23.60     6.10     8.35
##  18     7.13 0.546 23.60     6.00     8.25
## 
## Results are averaged over the levels of: exp 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
# Extração da matriz de funções lineares.
grid <- attr(emm, "grid")
L <- attr(emm, "linfct")
rownames(L) <- grid[[1]]

# Contrastes par a par.
ctr <- summary(glht(mm0, linfct = all_pairwise(L)),
               test = adjusted(type = "fdr"))

# Erros padrões de vários tamanhos conforme estrutura de associação.
v <- c("coefficients", "sigma", "tstat", "pvalues")
ctr$test[v] %>%
    as.data.frame() %>%
    split(., round(.$sigma, 4)) %>%
    map(head, n = 10)
## $`0.3572`
##      coefficients     sigma     tstat      pvalues
## 1vs2   -0.6166667 0.3571994 -1.726393 0.1953686366
## 1vs3   -1.5166667 0.3571994 -4.245995 0.0008324193
## 2vs3   -0.9000000 0.3571994 -2.519601 0.0599188193
## 
## $`0.5456`
##       coefficients     sigma      tstat    pvalues
## 1vs4     0.3888889 0.5456311  0.7127323 0.63885745
## 1vs5     0.6388889 0.5456311  1.1709173 0.39329466
## 1vs6    -0.1611111 0.5456311 -0.2952748 0.87664885
## 1vs7    -0.5611111 0.5456311 -1.0283709 0.45254429
## 1vs8    -0.5111111 0.5456311 -0.9367339 0.50623391
## 1vs9     0.1055556 0.5456311  0.1934559 0.93105435
## 1vs10   -1.2944444 0.5456311 -2.3723803 0.07511403
## 1vs11   -0.5944444 0.5456311 -1.0894622 0.41802344
## 1vs12   -0.5944444 0.5456311 -1.0894622 0.41802344
## 1vs13   -0.2944444 0.5456311 -0.5396402 0.73922228
## 
## $`0.6187`
##      coefficients     sigma       tstat   pvalues
## 4vs5         0.25 0.6186875  0.40408122 0.8138094
## 4vs6        -0.55 0.6186875 -0.88897869 0.5298539
## 4vs7        -0.95 0.6186875 -1.53550864 0.2577408
## 4vs8        -0.90 0.6186875 -1.45469240 0.2822839
## 5vs6        -0.80 0.6186875 -1.29305991 0.3331836
## 5vs7        -1.20 0.6186875 -1.93958986 0.1616402
## 5vs8        -1.15 0.6186875 -1.85877362 0.1692643
## 6vs7        -0.40 0.6186875 -0.64652995 0.6831400
## 6vs8        -0.35 0.6186875 -0.56571371 0.7227523
## 7vs8         0.05 0.6186875  0.08081624 0.9737754
## 
## $`0.7144`
##       coefficients     sigma      tstat      pvalues
## 4vs9    -0.2833333 0.7143988 -0.3966039 0.8140301309
## 4vs10   -1.6833333 0.7143988 -2.3562937 0.0763276441
## 4vs11   -0.9833333 0.7143988 -1.3764488 0.3036289266
## 4vs12   -0.9833333 0.7143988 -1.3764488 0.3036289266
## 4vs13   -0.6833333 0.7143988 -0.9565152 0.4984445537
## 4vs14   -2.0333333 0.7143988 -2.8462161 0.0270762013
## 4vs15   -2.3333333 0.7143988 -3.2661496 0.0128308891
## 4vs16   -3.1333333 0.7143988 -4.3859724 0.0005888908
## 4vs17   -1.9833333 0.7143988 -2.7762272 0.0323617163
## 4vs18   -1.8833333 0.7143988 -2.6362493 0.0442265534
# As mesmas comparações múltiplas.
results_mm0 <- wzRfun::apmc(L,
                            model = mm0,
                            focus = "linh",
                            test = "fdr")
results_mm0
##    linh      fit      lwr      upr cld
## 1     1 5.633333 4.933599 6.333067  de
## 2     2 6.250000 5.550266 6.949734 bce
## 3     3 7.150000 6.450266 7.849734  ab
## 4     4 5.244444 4.175265 6.313623  de
## 5     5 4.994444 3.925265 6.063623   e
## 6     6 5.794444 4.725265 6.863623 bce
## 7     7 6.194444 5.125265 7.263623 bce
## 8     8 6.144444 5.075265 7.213623 bce
## 9     9 5.527778 4.458599 6.596957  ce
## 10   10 6.927778 5.858599 7.996957 acd
## 11   11 6.227778 5.158599 7.296957 bce
## 12   12 6.227778 5.158599 7.296957 bce
## 13   13 5.927778 4.858599 6.996957 bce
## 14   14 7.277778 6.208599 8.346957  ac
## 15   15 7.577778 6.508599 8.646957  ab
## 16   16 8.377778 7.308599 9.446957   a
## 17   17 7.227778 6.158599 8.296957  ac
## 18   18 7.127778 6.058599 8.196957  ac
# Gráfico de segmentos para as estimativas intervalares.
ggplot(data = results_mm0,
       mapping = aes(x = fit, y = reorder(linh, fit))) +
    geom_point() +
    geom_errorbarh(mapping = aes(xmin = lwr, xmax = upr),
                   height = 0) +
    geom_label(mapping = aes(label = sprintf("%0.2f%s", fit, cld)),
               label.padding = unit(0.15, "lines"),
               fill = "black",
               colour = "white",
               size = 3,
               nudge_x = 0.25,
               vjust = 0.5) +
    labs(x = "Produção",
         y = "Linhagens")

18.3 ZimmermannTb8.5

Os dados em ZimmermannTb8.5 são de um experimento para avaliação de cultivares de feijão em um delineamento de blocos aumentados de Federer. O experimento teve \(b = 10\) blocos de tamanho \(k = 9\) para acomodar \(t = 54\) linhagens das quais 4 são tratamentos comuns a todos os blocos.

da <- labestData::ZimmermannTb8.5
str(da)
## 'data.frame':    90 obs. of  3 variables:
##  $ bloc: Factor w/ 10 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 2 ...
##  $ linh: Factor w/ 54 levels "1","2","3","4",..: 9 5 8 3 4 1 2 6 7 14 ...
##  $ prod: num  761 1516 1692 1563 2019 ...
with(da, table(linh, bloc)) %>%
    addmargins() %>%
    print.table(zero.print = ".")
##      bloc
## linh   1  2  3  4  5  6  7  8  9 10 Sum
##   1    1  1  1  1  1  1  1  1  1  1  10
##   2    1  1  1  1  1  1  1  1  1  1  10
##   3    1  1  1  1  1  1  1  1  1  1  10
##   4    1  1  1  1  1  1  1  1  1  1  10
##   5    1  .  .  .  .  .  .  .  .  .   1
##   6    1  .  .  .  .  .  .  .  .  .   1
##   7    1  .  .  .  .  .  .  .  .  .   1
##   8    1  .  .  .  .  .  .  .  .  .   1
##   9    1  .  .  .  .  .  .  .  .  .   1
##   17   .  1  .  .  .  .  .  .  .  .   1
##   18   .  1  .  .  .  .  .  .  .  .   1
##   19   .  1  .  .  .  .  .  .  .  .   1
##   20   .  1  .  .  .  .  .  .  .  .   1
##   21   .  1  .  .  .  .  .  .  .  .   1
##   29   .  .  1  .  .  .  .  .  .  .   1
##   30   .  .  1  .  .  .  .  .  .  .   1
##   31   .  .  1  .  .  .  .  .  .  .   1
##   32   .  .  1  .  .  .  .  .  .  .   1
##   33   .  .  1  .  .  .  .  .  .  .   1
##   41   .  .  .  1  .  .  .  .  .  .   1
##   42   .  .  .  1  .  .  .  .  .  .   1
##   43   .  .  .  1  .  .  .  .  .  .   1
##   44   .  .  .  1  .  .  .  .  .  .   1
##   45   .  .  .  1  .  .  .  .  .  .   1
##   53   .  .  .  .  1  .  .  .  .  .   1
##   54   .  .  .  .  1  .  .  .  .  .   1
##   55   .  .  .  .  1  .  .  .  .  .   1
##   56   .  .  .  .  1  .  .  .  .  .   1
##   57   .  .  .  .  1  .  .  .  .  .   1
##   65   .  .  .  .  .  1  .  .  .  .   1
##   66   .  .  .  .  .  1  .  .  .  .   1
##   67   .  .  .  .  .  1  .  .  .  .   1
##   68   .  .  .  .  .  1  .  .  .  .   1
##   69   .  .  .  .  .  1  .  .  .  .   1
##   77   .  .  .  .  .  .  1  .  .  .   1
##   78   .  .  .  .  .  .  1  .  .  .   1
##   79   .  .  .  .  .  .  1  .  .  .   1
##   80   .  .  .  .  .  .  1  .  .  .   1
##   81   .  .  .  .  .  .  1  .  .  .   1
##   89   .  .  .  .  .  .  .  1  .  .   1
##   90   .  .  .  .  .  .  .  1  .  .   1
##   91   .  .  .  .  .  .  .  1  .  .   1
##   92   .  .  .  .  .  .  .  1  .  .   1
##   93   .  .  .  .  .  .  .  1  .  .   1
##   101  .  .  .  .  .  .  .  .  1  .   1
##   102  .  .  .  .  .  .  .  .  1  .   1
##   103  .  .  .  .  .  .  .  .  1  .   1
##   104  .  .  .  .  .  .  .  .  1  .   1
##   105  .  .  .  .  .  .  .  .  1  .   1
##   113  .  .  .  .  .  .  .  .  .  1   1
##   114  .  .  .  .  .  .  .  .  .  1   1
##   115  .  .  .  .  .  .  .  .  .  1   1
##   116  .  .  .  .  .  .  .  .  .  1   1
##   117  .  .  .  .  .  .  .  .  .  1   1
##   Sum  9  9  9  9  9  9  9  9  9  9  90
library(igraph)

# Todos os possíveis pares.
pares <- apply(combn(sort(as.character(levels(da$linh))), m = 2),
               MARGIN = 2,
               FUN = paste0,
               collapse = "_") %>%
    tibble(name = ., value = 0)

# Quantas vezes cada par ocorre junto.
by(data = as.character(da$linh),
   INDICES = da$bloc,
   FUN = function(x) {
       apply(combn(sort(x), m = 2),
             MARGIN = 2,
             FUN = paste0,
             collapse = "_")
   }) %>%
    flatten_chr() %>%
    table() %>%
    c() %>%
    enframe() %>%
    bind_rows(pares) %>%
    distinct(name, .keep_all = TRUE) %>%
    split(x = .$name, f = .$value)

edg <- by(data = as.integer(da$linh),
          INDICES = da$bloc,
          FUN = combn,
          m = 2) %>%
    flatten_int()

p <- 4
pal <- sample(colors(), size = nlevels(da$bloc) + 1)

clr <- rep(head(pal, n = -1),
           tapply(da$bloc, da$bloc, length) - p)
clr <- append(clr, rep(tail(pal, n = 1), p),
              after = 0)

ghp <- graph(edg, directed = FALSE)
plot(ghp,
     vertex.color = clr,
     vertex.size = 7,
     layout = layout_nicely,
     edge.curved = FALSE)
# Modelo de efeitos fixos.
m0 <- lm(terms(prod ~ bloc + linh, keep.order = TRUE),
         data = da)

# Quado de anova com hipóteses marginais.
Anova(m0)
## Anova Table (Type II tests)
## 
## Response: prod
##            Sum Sq Df F value    Pr(>F)    
## bloc       492838  9  2.1975   0.05508 .  
## linh      6403550 53  4.8486 1.716e-05 ***
## Residuals  672811 27                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Médias marginais ajustadas.
emm <- emmeans(m0, specs = ~linh)
emm
##  linh emmean    SE df lower.CL upper.CL
##  1      1841  49.9 27     1738     1943
##  2      1598  49.9 27     1496     1701
##  3      1773  49.9 27     1670     1875
##  4      1983  49.9 27     1881     2086
##  5      1501 174.7 27     1142     1859
##  6      1230 174.7 27      871     1588
##  7      1188 174.7 27      829     1546
##  8      1677 174.7 27     1318     2035
##  9       746 174.7 27      387     1104
##  17     1652 174.7 27     1293     2010
##  18     1622 174.7 27     1263     1980
##  19     1903 174.7 27     1544     2261
##  20     1754 174.7 27     1395     2112
##  21     1402 174.7 27     1043     1760
##  29     1231 174.7 27      872     1589
##  30     1203 174.7 27      844     1561
##  31     1594 174.7 27     1235     1952
##  32     1274 174.7 27      915     1632
##  33     1783 174.7 27     1424     2141
##  41     1585 174.7 27     1227     1944
##  42     1447 174.7 27     1089     1806
##  43     1304 174.7 27      946     1663
##  44     1612 174.7 27     1254     1971
##  45     1363 174.7 27     1005     1722
##  53     1838 174.7 27     1480     2197
##  54     1177 174.7 27      819     1536
##  55     1208 174.7 27      850     1567
##  56     1474 174.7 27     1116     1833
##  57     1468 174.7 27     1110     1827
##  65     1221 174.7 27      863     1580
##  66     1488 174.7 27     1130     1847
##  67     1356 174.7 27      998     1715
##  68     1528 174.7 27     1170     1887
##  69     1898 174.7 27     1540     2257
##  77     1767 174.7 27     1408     2125
##  78     2243 174.7 27     1884     2601
##  79     2535 174.7 27     2176     2893
##  80     2095 174.7 27     1736     2453
##  81     1694 174.7 27     1335     2052
##  89     1992 174.7 27     1634     2351
##  90     1217 174.7 27      859     1576
##  91     1266 174.7 27      908     1625
##  92     1210 174.7 27      852     1569
##  93     1490 174.7 27     1132     1849
##  101    1422 174.7 27     1064     1781
##  102    1874 174.7 27     1516     2233
##  103    1868 174.7 27     1510     2227
##  104    1440 174.7 27     1082     1799
##  105    1792 174.7 27     1434     2151
##  113    2100 174.7 27     1742     2459
##  114    1370 174.7 27     1012     1729
##  115    2276 174.7 27     1918     2635
##  116    1525 174.7 27     1167     1884
##  117    2271 174.7 27     1913     2630
## 
## Results are averaged over the levels of: bloc 
## Confidence level used: 0.95
# Extração da matriz de funções lineares.
L <- attr(emm, "linfct")
grid <- attr(emm, "grid")
rownames(L) <- grid[[1]]

# Entenda como são obtidas as médias marginais.
MASS::fractions(t(L))
##             1    2    3    4    5    6    7    8    9    17   18  
## (Intercept)    1    1    1    1    1    1    1    1    1    1    1
## bloc2       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc3       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc4       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc5       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc6       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc7       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc8       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc9       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc10      1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## linh2          0    1    0    0    0    0    0    0    0    0    0
## linh3          0    0    1    0    0    0    0    0    0    0    0
## linh4          0    0    0    1    0    0    0    0    0    0    0
## linh5          0    0    0    0    1    0    0    0    0    0    0
## linh6          0    0    0    0    0    1    0    0    0    0    0
## linh7          0    0    0    0    0    0    1    0    0    0    0
## linh8          0    0    0    0    0    0    0    1    0    0    0
## linh9          0    0    0    0    0    0    0    0    1    0    0
## linh17         0    0    0    0    0    0    0    0    0    1    0
## linh18         0    0    0    0    0    0    0    0    0    0    1
## linh19         0    0    0    0    0    0    0    0    0    0    0
## linh20         0    0    0    0    0    0    0    0    0    0    0
## linh21         0    0    0    0    0    0    0    0    0    0    0
## linh29         0    0    0    0    0    0    0    0    0    0    0
## linh30         0    0    0    0    0    0    0    0    0    0    0
## linh31         0    0    0    0    0    0    0    0    0    0    0
## linh32         0    0    0    0    0    0    0    0    0    0    0
## linh33         0    0    0    0    0    0    0    0    0    0    0
## linh41         0    0    0    0    0    0    0    0    0    0    0
## linh42         0    0    0    0    0    0    0    0    0    0    0
## linh43         0    0    0    0    0    0    0    0    0    0    0
## linh44         0    0    0    0    0    0    0    0    0    0    0
## linh45         0    0    0    0    0    0    0    0    0    0    0
## linh53         0    0    0    0    0    0    0    0    0    0    0
## linh54         0    0    0    0    0    0    0    0    0    0    0
## linh55         0    0    0    0    0    0    0    0    0    0    0
## linh56         0    0    0    0    0    0    0    0    0    0    0
## linh57         0    0    0    0    0    0    0    0    0    0    0
## linh65         0    0    0    0    0    0    0    0    0    0    0
## linh66         0    0    0    0    0    0    0    0    0    0    0
## linh67         0    0    0    0    0    0    0    0    0    0    0
## linh68         0    0    0    0    0    0    0    0    0    0    0
## linh69         0    0    0    0    0    0    0    0    0    0    0
## linh77         0    0    0    0    0    0    0    0    0    0    0
## linh78         0    0    0    0    0    0    0    0    0    0    0
## linh79         0    0    0    0    0    0    0    0    0    0    0
## linh80         0    0    0    0    0    0    0    0    0    0    0
## linh81         0    0    0    0    0    0    0    0    0    0    0
## linh89         0    0    0    0    0    0    0    0    0    0    0
## linh90         0    0    0    0    0    0    0    0    0    0    0
## linh91         0    0    0    0    0    0    0    0    0    0    0
## linh92         0    0    0    0    0    0    0    0    0    0    0
## linh93         0    0    0    0    0    0    0    0    0    0    0
## linh101        0    0    0    0    0    0    0    0    0    0    0
## linh102        0    0    0    0    0    0    0    0    0    0    0
## linh103        0    0    0    0    0    0    0    0    0    0    0
## linh104        0    0    0    0    0    0    0    0    0    0    0
## linh105        0    0    0    0    0    0    0    0    0    0    0
## linh113        0    0    0    0    0    0    0    0    0    0    0
## linh114        0    0    0    0    0    0    0    0    0    0    0
## linh115        0    0    0    0    0    0    0    0    0    0    0
## linh116        0    0    0    0    0    0    0    0    0    0    0
## linh117        0    0    0    0    0    0    0    0    0    0    0
##             19   20   21   29   30   31   32   33   41   42   43  
## (Intercept)    1    1    1    1    1    1    1    1    1    1    1
## bloc2       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc3       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc4       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc5       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc6       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc7       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc8       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc9       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc10      1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## linh2          0    0    0    0    0    0    0    0    0    0    0
## linh3          0    0    0    0    0    0    0    0    0    0    0
## linh4          0    0    0    0    0    0    0    0    0    0    0
## linh5          0    0    0    0    0    0    0    0    0    0    0
## linh6          0    0    0    0    0    0    0    0    0    0    0
## linh7          0    0    0    0    0    0    0    0    0    0    0
## linh8          0    0    0    0    0    0    0    0    0    0    0
## linh9          0    0    0    0    0    0    0    0    0    0    0
## linh17         0    0    0    0    0    0    0    0    0    0    0
## linh18         0    0    0    0    0    0    0    0    0    0    0
## linh19         1    0    0    0    0    0    0    0    0    0    0
## linh20         0    1    0    0    0    0    0    0    0    0    0
## linh21         0    0    1    0    0    0    0    0    0    0    0
## linh29         0    0    0    1    0    0    0    0    0    0    0
## linh30         0    0    0    0    1    0    0    0    0    0    0
## linh31         0    0    0    0    0    1    0    0    0    0    0
## linh32         0    0    0    0    0    0    1    0    0    0    0
## linh33         0    0    0    0    0    0    0    1    0    0    0
## linh41         0    0    0    0    0    0    0    0    1    0    0
## linh42         0    0    0    0    0    0    0    0    0    1    0
## linh43         0    0    0    0    0    0    0    0    0    0    1
## linh44         0    0    0    0    0    0    0    0    0    0    0
## linh45         0    0    0    0    0    0    0    0    0    0    0
## linh53         0    0    0    0    0    0    0    0    0    0    0
## linh54         0    0    0    0    0    0    0    0    0    0    0
## linh55         0    0    0    0    0    0    0    0    0    0    0
## linh56         0    0    0    0    0    0    0    0    0    0    0
## linh57         0    0    0    0    0    0    0    0    0    0    0
## linh65         0    0    0    0    0    0    0    0    0    0    0
## linh66         0    0    0    0    0    0    0    0    0    0    0
## linh67         0    0    0    0    0    0    0    0    0    0    0
## linh68         0    0    0    0    0    0    0    0    0    0    0
## linh69         0    0    0    0    0    0    0    0    0    0    0
## linh77         0    0    0    0    0    0    0    0    0    0    0
## linh78         0    0    0    0    0    0    0    0    0    0    0
## linh79         0    0    0    0    0    0    0    0    0    0    0
## linh80         0    0    0    0    0    0    0    0    0    0    0
## linh81         0    0    0    0    0    0    0    0    0    0    0
## linh89         0    0    0    0    0    0    0    0    0    0    0
## linh90         0    0    0    0    0    0    0    0    0    0    0
## linh91         0    0    0    0    0    0    0    0    0    0    0
## linh92         0    0    0    0    0    0    0    0    0    0    0
## linh93         0    0    0    0    0    0    0    0    0    0    0
## linh101        0    0    0    0    0    0    0    0    0    0    0
## linh102        0    0    0    0    0    0    0    0    0    0    0
## linh103        0    0    0    0    0    0    0    0    0    0    0
## linh104        0    0    0    0    0    0    0    0    0    0    0
## linh105        0    0    0    0    0    0    0    0    0    0    0
## linh113        0    0    0    0    0    0    0    0    0    0    0
## linh114        0    0    0    0    0    0    0    0    0    0    0
## linh115        0    0    0    0    0    0    0    0    0    0    0
## linh116        0    0    0    0    0    0    0    0    0    0    0
## linh117        0    0    0    0    0    0    0    0    0    0    0
##             44   45   53   54   55   56   57   65   66   67   68  
## (Intercept)    1    1    1    1    1    1    1    1    1    1    1
## bloc2       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc3       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc4       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc5       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc6       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc7       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc8       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc9       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc10      1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## linh2          0    0    0    0    0    0    0    0    0    0    0
## linh3          0    0    0    0    0    0    0    0    0    0    0
## linh4          0    0    0    0    0    0    0    0    0    0    0
## linh5          0    0    0    0    0    0    0    0    0    0    0
## linh6          0    0    0    0    0    0    0    0    0    0    0
## linh7          0    0    0    0    0    0    0    0    0    0    0
## linh8          0    0    0    0    0    0    0    0    0    0    0
## linh9          0    0    0    0    0    0    0    0    0    0    0
## linh17         0    0    0    0    0    0    0    0    0    0    0
## linh18         0    0    0    0    0    0    0    0    0    0    0
## linh19         0    0    0    0    0    0    0    0    0    0    0
## linh20         0    0    0    0    0    0    0    0    0    0    0
## linh21         0    0    0    0    0    0    0    0    0    0    0
## linh29         0    0    0    0    0    0    0    0    0    0    0
## linh30         0    0    0    0    0    0    0    0    0    0    0
## linh31         0    0    0    0    0    0    0    0    0    0    0
## linh32         0    0    0    0    0    0    0    0    0    0    0
## linh33         0    0    0    0    0    0    0    0    0    0    0
## linh41         0    0    0    0    0    0    0    0    0    0    0
## linh42         0    0    0    0    0    0    0    0    0    0    0
## linh43         0    0    0    0    0    0    0    0    0    0    0
## linh44         1    0    0    0    0    0    0    0    0    0    0
## linh45         0    1    0    0    0    0    0    0    0    0    0
## linh53         0    0    1    0    0    0    0    0    0    0    0
## linh54         0    0    0    1    0    0    0    0    0    0    0
## linh55         0    0    0    0    1    0    0    0    0    0    0
## linh56         0    0    0    0    0    1    0    0    0    0    0
## linh57         0    0    0    0    0    0    1    0    0    0    0
## linh65         0    0    0    0    0    0    0    1    0    0    0
## linh66         0    0    0    0    0    0    0    0    1    0    0
## linh67         0    0    0    0    0    0    0    0    0    1    0
## linh68         0    0    0    0    0    0    0    0    0    0    1
## linh69         0    0    0    0    0    0    0    0    0    0    0
## linh77         0    0    0    0    0    0    0    0    0    0    0
## linh78         0    0    0    0    0    0    0    0    0    0    0
## linh79         0    0    0    0    0    0    0    0    0    0    0
## linh80         0    0    0    0    0    0    0    0    0    0    0
## linh81         0    0    0    0    0    0    0    0    0    0    0
## linh89         0    0    0    0    0    0    0    0    0    0    0
## linh90         0    0    0    0    0    0    0    0    0    0    0
## linh91         0    0    0    0    0    0    0    0    0    0    0
## linh92         0    0    0    0    0    0    0    0    0    0    0
## linh93         0    0    0    0    0    0    0    0    0    0    0
## linh101        0    0    0    0    0    0    0    0    0    0    0
## linh102        0    0    0    0    0    0    0    0    0    0    0
## linh103        0    0    0    0    0    0    0    0    0    0    0
## linh104        0    0    0    0    0    0    0    0    0    0    0
## linh105        0    0    0    0    0    0    0    0    0    0    0
## linh113        0    0    0    0    0    0    0    0    0    0    0
## linh114        0    0    0    0    0    0    0    0    0    0    0
## linh115        0    0    0    0    0    0    0    0    0    0    0
## linh116        0    0    0    0    0    0    0    0    0    0    0
## linh117        0    0    0    0    0    0    0    0    0    0    0
##             69   77   78   79   80   81   89   90   91   92   93  
## (Intercept)    1    1    1    1    1    1    1    1    1    1    1
## bloc2       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc3       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc4       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc5       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc6       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc7       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc8       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc9       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc10      1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## linh2          0    0    0    0    0    0    0    0    0    0    0
## linh3          0    0    0    0    0    0    0    0    0    0    0
## linh4          0    0    0    0    0    0    0    0    0    0    0
## linh5          0    0    0    0    0    0    0    0    0    0    0
## linh6          0    0    0    0    0    0    0    0    0    0    0
## linh7          0    0    0    0    0    0    0    0    0    0    0
## linh8          0    0    0    0    0    0    0    0    0    0    0
## linh9          0    0    0    0    0    0    0    0    0    0    0
## linh17         0    0    0    0    0    0    0    0    0    0    0
## linh18         0    0    0    0    0    0    0    0    0    0    0
## linh19         0    0    0    0    0    0    0    0    0    0    0
## linh20         0    0    0    0    0    0    0    0    0    0    0
## linh21         0    0    0    0    0    0    0    0    0    0    0
## linh29         0    0    0    0    0    0    0    0    0    0    0
## linh30         0    0    0    0    0    0    0    0    0    0    0
## linh31         0    0    0    0    0    0    0    0    0    0    0
## linh32         0    0    0    0    0    0    0    0    0    0    0
## linh33         0    0    0    0    0    0    0    0    0    0    0
## linh41         0    0    0    0    0    0    0    0    0    0    0
## linh42         0    0    0    0    0    0    0    0    0    0    0
## linh43         0    0    0    0    0    0    0    0    0    0    0
## linh44         0    0    0    0    0    0    0    0    0    0    0
## linh45         0    0    0    0    0    0    0    0    0    0    0
## linh53         0    0    0    0    0    0    0    0    0    0    0
## linh54         0    0    0    0    0    0    0    0    0    0    0
## linh55         0    0    0    0    0    0    0    0    0    0    0
## linh56         0    0    0    0    0    0    0    0    0    0    0
## linh57         0    0    0    0    0    0    0    0    0    0    0
## linh65         0    0    0    0    0    0    0    0    0    0    0
## linh66         0    0    0    0    0    0    0    0    0    0    0
## linh67         0    0    0    0    0    0    0    0    0    0    0
## linh68         0    0    0    0    0    0    0    0    0    0    0
## linh69         1    0    0    0    0    0    0    0    0    0    0
## linh77         0    1    0    0    0    0    0    0    0    0    0
## linh78         0    0    1    0    0    0    0    0    0    0    0
## linh79         0    0    0    1    0    0    0    0    0    0    0
## linh80         0    0    0    0    1    0    0    0    0    0    0
## linh81         0    0    0    0    0    1    0    0    0    0    0
## linh89         0    0    0    0    0    0    1    0    0    0    0
## linh90         0    0    0    0    0    0    0    1    0    0    0
## linh91         0    0    0    0    0    0    0    0    1    0    0
## linh92         0    0    0    0    0    0    0    0    0    1    0
## linh93         0    0    0    0    0    0    0    0    0    0    1
## linh101        0    0    0    0    0    0    0    0    0    0    0
## linh102        0    0    0    0    0    0    0    0    0    0    0
## linh103        0    0    0    0    0    0    0    0    0    0    0
## linh104        0    0    0    0    0    0    0    0    0    0    0
## linh105        0    0    0    0    0    0    0    0    0    0    0
## linh113        0    0    0    0    0    0    0    0    0    0    0
## linh114        0    0    0    0    0    0    0    0    0    0    0
## linh115        0    0    0    0    0    0    0    0    0    0    0
## linh116        0    0    0    0    0    0    0    0    0    0    0
## linh117        0    0    0    0    0    0    0    0    0    0    0
##             101  102  103  104  105  113  114  115  116  117 
## (Intercept)    1    1    1    1    1    1    1    1    1    1
## bloc2       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc3       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc4       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc5       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc6       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc7       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc8       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc9       1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## bloc10      1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10
## linh2          0    0    0    0    0    0    0    0    0    0
## linh3          0    0    0    0    0    0    0    0    0    0
## linh4          0    0    0    0    0    0    0    0    0    0
## linh5          0    0    0    0    0    0    0    0    0    0
## linh6          0    0    0    0    0    0    0    0    0    0
## linh7          0    0    0    0    0    0    0    0    0    0
## linh8          0    0    0    0    0    0    0    0    0    0
## linh9          0    0    0    0    0    0    0    0    0    0
## linh17         0    0    0    0    0    0    0    0    0    0
## linh18         0    0    0    0    0    0    0    0    0    0
## linh19         0    0    0    0    0    0    0    0    0    0
## linh20         0    0    0    0    0    0    0    0    0    0
## linh21         0    0    0    0    0    0    0    0    0    0
## linh29         0    0    0    0    0    0    0    0    0    0
## linh30         0    0    0    0    0    0    0    0    0    0
## linh31         0    0    0    0    0    0    0    0    0    0
## linh32         0    0    0    0    0    0    0    0    0    0
## linh33         0    0    0    0    0    0    0    0    0    0
## linh41         0    0    0    0    0    0    0    0    0    0
## linh42         0    0    0    0    0    0    0    0    0    0
## linh43         0    0    0    0    0    0    0    0    0    0
## linh44         0    0    0    0    0    0    0    0    0    0
## linh45         0    0    0    0    0    0    0    0    0    0
## linh53         0    0    0    0    0    0    0    0    0    0
## linh54         0    0    0    0    0    0    0    0    0    0
## linh55         0    0    0    0    0    0    0    0    0    0
## linh56         0    0    0    0    0    0    0    0    0    0
## linh57         0    0    0    0    0    0    0    0    0    0
## linh65         0    0    0    0    0    0    0    0    0    0
## linh66         0    0    0    0    0    0    0    0    0    0
## linh67         0    0    0    0    0    0    0    0    0    0
## linh68         0    0    0    0    0    0    0    0    0    0
## linh69         0    0    0    0    0    0    0    0    0    0
## linh77         0    0    0    0    0    0    0    0    0    0
## linh78         0    0    0    0    0    0    0    0    0    0
## linh79         0    0    0    0    0    0    0    0    0    0
## linh80         0    0    0    0    0    0    0    0    0    0
## linh81         0    0    0    0    0    0    0    0    0    0
## linh89         0    0    0    0    0    0    0    0    0    0
## linh90         0    0    0    0    0    0    0    0    0    0
## linh91         0    0    0    0    0    0    0    0    0    0
## linh92         0    0    0    0    0    0    0    0    0    0
## linh93         0    0    0    0    0    0    0    0    0    0
## linh101        1    0    0    0    0    0    0    0    0    0
## linh102        0    1    0    0    0    0    0    0    0    0
## linh103        0    0    1    0    0    0    0    0    0    0
## linh104        0    0    0    1    0    0    0    0    0    0
## linh105        0    0    0    0    1    0    0    0    0    0
## linh113        0    0    0    0    0    1    0    0    0    0
## linh114        0    0    0    0    0    0    1    0    0    0
## linh115        0    0    0    0    0    0    0    1    0    0
## linh116        0    0    0    0    0    0    0    0    1    0
## linh117        0    0    0    0    0    0    0    0    0    1
# Contrastes par a par.
ctr <- summary(glht(m0, linfct = all_pairwise(L)),
               test = adjusted(type = "fdr"))

# Erros padrões de vários tamanhos conforme estrutura de associação.
v <- c("coefficients", "sigma", "tstat", "pvalues")
ctr$test[v] %>%
    as.data.frame() %>%
    split(., round(.$sigma, 4)) %>%
    map(head, n = 5)
## $`70.5959`
##      coefficients    sigma      tstat     pvalues
## 1vs2        242.6 70.59593  3.4364588 0.018100710
## 1vs3         68.2 70.59593  0.9660614 0.532872490
## 1vs4       -142.3 70.59593 -2.0156970 0.159974826
## 2vs3       -174.4 70.59593 -2.4703975 0.082192175
## 2vs4       -384.9 70.59593 -5.4521559 0.001253037
## 
## $`181.7074`
##      coefficients    sigma     tstat      pvalues
## 1vs5      340.125 181.7074 1.8718281 0.1946125392
## 1vs6      611.125 181.7074 3.3632369 0.0202619743
## 1vs7      653.125 181.7074 3.5943777 0.0151433683
## 1vs8      164.125 181.7074 0.9032379 0.5633535256
## 1vs9     1095.125 181.7074 6.0268600 0.0005076058
## 
## $`223.2439`
##      coefficients    sigma      tstat    pvalues
## 5vs6          271 223.2439  1.2139188 0.42352320
## 5vs7          313 223.2439  1.4020538 0.34771778
## 5vs8         -176 223.2439 -0.7883753 0.61910926
## 5vs9          755 223.2439  3.3819509 0.01988748
## 6vs7           42 223.2439  0.1881350 0.92876332
## 
## $`249.5943`
##       coefficients    sigma      tstat   pvalues
## 5vs17         -151 249.5943 -0.6049818 0.7127985
## 5vs18         -121 249.5943 -0.4847867 0.7773143
## 5vs19         -402 249.5943 -1.6106137 0.2683567
## 5vs20         -253 249.5943 -1.0136450 0.5106724
## 5vs21           99 249.5943  0.3966437 0.8236821
# Comparações múltiplas.
results_m0 <- wzRfun::apmc(X = L,
                           model = m0,
                           focus = "linh",
                           test = "fdr")
results_m0
##    linh      fit       lwr      upr      cld
## 1     1 1840.900 1738.4750 1943.325      cdi
## 2     2 1598.300 1495.8750 1700.725      fhl
## 3     3 1772.700 1670.2750 1875.125    cfijk
## 4     4 1983.200 1880.7750 2085.625       ad
## 5     5 1500.775 1142.2874 1859.263    dhijl
## 6     6 1229.775  871.2874 1588.263       lm
## 7     7 1187.775  829.2874 1546.263      ghm
## 8     8 1676.775 1318.2874 2035.263  cdfhijl
## 9     9  745.775  387.2874 1104.263        m
## 10   17 1651.775 1293.2874 2010.263  cdfhijl
## 11   18 1621.775 1263.2874 1980.263  cdfhijl
## 12   19 1902.775 1544.2874 2261.263  bdefijl
## 13   20 1753.775 1395.2874 2112.263  cdfhijl
## 14   21 1401.775 1043.2874 1760.263    fijlm
## 15   29 1230.775  872.2874 1589.263       lm
## 16   30 1202.775  844.2874 1561.263       lm
## 17   31 1593.775 1235.2874 1952.263  cdfhijl
## 18   32 1273.775  915.2874 1632.263      jlm
## 19   33 1782.775 1424.2874 2141.263  cdfhijl
## 20   41 1585.025 1226.5374 1943.513  cdfhijl
## 21   42 1447.025 1088.5374 1805.513    fijlm
## 22   43 1304.025  945.5374 1662.513      klm
## 23   44 1612.025 1253.5374 1970.513  cdfhijl
## 24   45 1363.025 1004.5374 1721.513      ilm
## 25   53 1838.025 1479.5374 2196.513 bdefgijl
## 26   54 1177.025  818.5374 1535.513       hm
## 27   55 1208.025  849.5374 1566.513       lm
## 28   56 1474.025 1115.5374 1832.513    dhijl
## 29   57 1468.025 1109.5374 1826.513    fhijl
## 30   65 1221.275  862.7874 1579.763      ehm
## 31   66 1488.275 1129.7874 1846.763    dhijl
## 32   67 1356.275  997.7874 1714.763      ilm
## 33   68 1528.275 1169.7874 1886.763    dhijl
## 34   69 1898.275 1539.7874 2256.763   bdfijl
## 35   77 1766.775 1408.2874 2125.263  cdfhijl
## 36   78 2242.775 1884.2874 2601.263      abc
## 37   79 2534.775 2176.2874 2893.263        b
## 38   80 2094.775 1736.2874 2453.263      bdf
## 39   81 1693.775 1335.2874 2052.263  cdfhijl
## 40   89 1992.275 1633.7874 2350.763    bdfik
## 41   90 1217.275  858.7874 1575.763       lm
## 42   91 1266.275  907.7874 1624.763      jlm
## 43   92 1210.275  851.7874 1568.763       lm
## 44   93 1490.275 1131.7874 1848.763    dhijl
## 45  101 1422.025 1063.5374 1780.513    fijlm
## 46  102 1874.025 1515.5374 2232.513  bdfhijl
## 47  103 1868.025 1509.5374 2226.513  bdfhijl
## 48  104 1440.025 1081.5374 1798.513    fijlm
## 49  105 1792.025 1433.5374 2150.513  cdfhijl
## 50  113 2100.275 1741.7874 2458.763      bdf
## 51  114 1370.275 1011.7874 1728.763      ilm
## 52  115 2276.275 1917.7874 2634.763      abc
## 53  116 1525.275 1166.7874 1883.763    dhijl
## 54  117 2271.275 1912.7874 2629.763      abc
# Gráfico de segmentos para as estimativas intervalares.
ggplot(data = results_m0,
       mapping = aes(x = fit, y = reorder(linh, fit))) +
    geom_point() +
    geom_errorbarh(mapping = aes(xmin = lwr, xmax = upr),
                   height = 0) +
    geom_label(mapping = aes(
                   x = min(lwr),
                   label = sprintf("%0.0f %s", fit, cld)),
               label.padding = unit(0.15, "lines"),
               fill = "black",
               colour = "white",
               size = 3,
               nudge_x = -80,
               hjust = 0,
               vjust = 0.5) +
    labs(x = "Produção",
         y = "Linhagens")

# Ajuste do modelo de efeito aleatório de bloc.
mm0 <- lmer(prod ~ (1 | bloc) + linh, data = da)

# Quadro de teste de Wald.
anova(mm0)
## Type III Analysis of Variance Table with Satterthwaite's method
##       Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## linh 7281233  137382    53 28.027  5.5131 3.277e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Estimativas dos parâmetros dos termos de efeito.
summary(mm0)
## Linear mixed model fit by REML. t-tests use Satterthwaite's  method
##  [lmerModLmerTest]
## Formula: prod ~ (1 | bloc) + linh
##    Data: da
## 
## REML criterion at convergence: 482.9
## 
## Scaled residuals: 
##    Min     1Q Median     3Q    Max 
## -2.287  0.000  0.000  0.000  1.693 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  bloc     (Intercept)  7460     86.37  
##  Residual             24919    157.86  
## Number of obs: 90, groups:  bloc, 10
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  1840.90      56.90    31.05  32.352  < 2e-16 ***
## linh2        -242.60      70.60    27.00  -3.436 0.001923 ** 
## linh3         -68.20      70.60    27.00  -0.966 0.342587    
## linh4         142.30      70.60    27.00   2.016 0.053884 .  
## linh5        -333.20     174.55    31.37  -1.909 0.065453 .  
## linh6        -604.20     174.55    31.37  -3.462 0.001572 ** 
## linh7        -646.20     174.55    31.37  -3.702 0.000819 ***
## linh8        -157.20     174.55    31.37  -0.901 0.374659    
## linh9       -1088.20     174.55    31.37  -6.234 5.99e-07 ***
## linh17       -128.04     174.55    31.37  -0.734 0.468646    
## linh18       -158.04     174.55    31.37  -0.905 0.372121    
## linh19        122.96     174.55    31.37   0.704 0.486361    
## linh20        -26.04     174.55    31.37  -0.149 0.882340    
## linh21       -378.04     174.55    31.37  -2.166 0.038034 *  
## linh29       -678.74     174.55    31.37  -3.889 0.000490 ***
## linh30       -706.74     174.55    31.37  -4.049 0.000313 ***
## linh31       -315.74     174.55    31.37  -1.809 0.080058 .  
## linh32       -635.74     174.55    31.37  -3.642 0.000965 ***
## linh33       -126.74     174.55    31.37  -0.726 0.473163    
## linh41       -359.64     174.55    31.37  -2.060 0.047731 *  
## linh42       -497.64     174.55    31.37  -2.851 0.007640 ** 
## linh43       -640.64     174.55    31.37  -3.670 0.000893 ***
## linh44       -332.64     174.55    31.37  -1.906 0.065881 .  
## linh45       -581.64     174.55    31.37  -3.332 0.002217 ** 
## linh53         13.04     174.55    31.37   0.075 0.940918    
## linh54       -647.96     174.55    31.37  -3.712 0.000797 ***
## linh55       -616.96     174.55    31.37  -3.535 0.001291 ** 
## linh56       -350.96     174.55    31.37  -2.011 0.053018 .  
## linh57       -356.96     174.55    31.37  -2.045 0.049312 *  
## linh65       -593.36     174.55    31.37  -3.399 0.001855 ** 
## linh66       -326.36     174.55    31.37  -1.870 0.070876 .  
## linh67       -458.36     174.55    31.37  -2.626 0.013241 *  
## linh68       -286.36     174.55    31.37  -1.641 0.110873    
## linh69         83.64     174.55    31.37   0.479 0.635115    
## linh77        -20.33     174.55    31.37  -0.116 0.908039    
## linh78        455.67     174.55    31.37   2.611 0.013737 *  
## linh79        747.67     174.55    31.37   4.284 0.000162 ***
## linh80        307.67     174.55    31.37   1.763 0.087688 .  
## linh81        -93.33     174.55    31.37  -0.535 0.596642    
## linh89        118.49     174.55    31.37   0.679 0.502227    
## linh90       -656.51     174.55    31.37  -3.761 0.000696 ***
## linh91       -607.51     174.55    31.37  -3.481 0.001494 ** 
## linh92       -663.51     174.55    31.37  -3.801 0.000624 ***
## linh93       -383.51     174.55    31.37  -2.197 0.035512 *  
## linh101      -413.88     174.55    31.37  -2.371 0.024047 *  
## linh102        38.12     174.55    31.37   0.218 0.828538    
## linh103        32.12     174.55    31.37   0.184 0.855185    
## linh104      -395.88     174.55    31.37  -2.268 0.030354 *  
## linh105       -43.88     174.55    31.37  -0.251 0.803144    
## linh113       295.65     174.55    31.37   1.694 0.100200    
## linh114      -434.35     174.55    31.37  -2.488 0.018340 *  
## linh115       471.65     174.55    31.37   2.702 0.011017 *  
## linh116      -279.35     174.55    31.37  -1.600 0.119529    
## linh117       466.65     174.55    31.37   2.674 0.011809 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation matrix not shown by default, as p = 54 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
# Médias marginais ajustadas.
emm <- emmeans(mm0, specs = ~linh)
emm
##  linh emmean    SE   df lower.CL upper.CL
##  1      1841  56.9 31.1     1725     1957
##  2      1598  56.9 31.1     1482     1714
##  3      1773  56.9 31.1     1657     1889
##  4      1983  56.9 31.1     1867     2099
##  5      1508 173.9 33.7     1154     1861
##  6      1237 173.9 33.7      883     1590
##  7      1195 173.9 33.7      841     1548
##  8      1684 173.9 33.7     1330     2037
##  9       753 173.9 33.7      399     1106
##  17     1713 173.9 33.7     1359     2066
##  18     1683 173.9 33.7     1329     2036
##  19     1964 173.9 33.7     1610     2317
##  20     1815 173.9 33.7     1461     2168
##  21     1463 173.9 33.7     1109     1816
##  29     1162 173.9 33.7      809     1516
##  30     1134 173.9 33.7      781     1488
##  31     1525 173.9 33.7     1172     1879
##  32     1205 173.9 33.7      852     1559
##  33     1714 173.9 33.7     1361     2068
##  41     1481 173.9 33.7     1128     1835
##  42     1343 173.9 33.7      990     1697
##  43     1200 173.9 33.7      847     1554
##  44     1508 173.9 33.7     1155     1862
##  45     1259 173.9 33.7      906     1613
##  53     1854 173.9 33.7     1500     2207
##  54     1193 173.9 33.7      839     1546
##  55     1224 173.9 33.7      870     1577
##  56     1490 173.9 33.7     1136     1843
##  57     1484 173.9 33.7     1130     1837
##  65     1248 173.9 33.7      894     1601
##  66     1515 173.9 33.7     1161     1868
##  67     1383 173.9 33.7     1029     1736
##  68     1555 173.9 33.7     1201     1908
##  69     1925 173.9 33.7     1571     2278
##  77     1821 173.9 33.7     1467     2174
##  78     2297 173.9 33.7     1943     2650
##  79     2589 173.9 33.7     2235     2942
##  80     2149 173.9 33.7     1795     2502
##  81     1748 173.9 33.7     1394     2101
##  89     1959 173.9 33.7     1606     2313
##  90     1184 173.9 33.7      831     1538
##  91     1233 173.9 33.7      880     1587
##  92     1177 173.9 33.7      824     1531
##  93     1457 173.9 33.7     1104     1811
##  101    1427 173.9 33.7     1074     1780
##  102    1879 173.9 33.7     1526     2232
##  103    1873 173.9 33.7     1520     2226
##  104    1445 173.9 33.7     1092     1798
##  105    1797 173.9 33.7     1444     2150
##  113    2137 173.9 33.7     1783     2490
##  114    1407 173.9 33.7     1053     1760
##  115    2313 173.9 33.7     1959     2666
##  116    1562 173.9 33.7     1208     1915
##  117    2308 173.9 33.7     1954     2661
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
# Extração da matriz de funções lineares.
grid <- attr(emm, "grid")
L <- attr(emm, "linfct")
rownames(L) <- grid[[1]]

# Contrastes par a par.
ctr <- summary(glht(mm0, linfct = all_pairwise(L)),
               test = adjusted(type = "fdr"))

# Erros padrões de vários tamanhos conforme estrutura de associação.
v <- c("coefficients", "sigma", "tstat", "pvalues")
ctr$test[v] %>%
    as.data.frame() %>%
    split(., round(.$sigma, 4)) %>%
    map(head, n = 10)
## $`70.5959`
##      coefficients    sigma      tstat      pvalues
## 1vs2        242.6 70.59593  3.4364589 4.402507e-03
## 1vs3         68.2 70.59593  0.9660614 4.837786e-01
## 1vs4       -142.3 70.59593 -2.0156970 1.144750e-01
## 2vs3       -174.4 70.59593 -2.4703975 4.576589e-02
## 2vs4       -384.9 70.59593 -5.4521559 2.967107e-06
## 3vs4       -210.5 70.59593 -2.9817584 1.402568e-02
## 
## $`174.5456`
##       coefficients    sigma      tstat      pvalues
## 1vs5     333.19672 174.5456  1.9089379 1.372476e-01
## 1vs6     604.19672 174.5456  3.4615407 4.117306e-03
## 1vs7     646.19672 174.5456  3.7021655 1.960902e-03
## 1vs8     157.19672 174.5456  0.9006054 5.190524e-01
## 1vs9    1088.19672 174.5456  6.2344550 1.081249e-07
## 1vs17    128.04468 174.5456  0.7335887 6.109110e-01
## 1vs18    158.04468 174.5456  0.9054635 5.164162e-01
## 1vs19   -122.95532 174.5456 -0.7044309 6.282357e-01
## 1vs20     26.04468 174.5456  0.1492142 9.457783e-01
## 1vs21    378.04468 174.5456  2.1658791 8.747687e-02
## 
## $`223.2439`
##      coefficients    sigma      tstat      pvalues
## 5vs6          271 223.2439  1.2139188 0.3712970179
## 5vs7          313 223.2439  1.4020538 0.2995158408
## 5vs8         -176 223.2439 -0.7883753 0.5789594716
## 5vs9          755 223.2439  3.3819509 0.0051240477
## 6vs7           42 223.2439  0.1881350 0.9286445682
## 6vs8         -447 223.2439 -2.0022941 0.1162606742
## 6vs9          484 223.2439  2.1680321 0.0873554306
## 7vs8         -489 223.2439 -2.1904292 0.0837452168
## 7vs9          442 223.2439  1.9798971 0.1204238024
## 8vs9          931 223.2439  4.1703263 0.0004067836
## 
## $`237.9654`
##       coefficients    sigma       tstat   pvalues
## 5vs17   -205.15204 237.9654 -0.86210878 0.5383603
## 5vs18   -175.15204 237.9654 -0.73604002 0.6100663
## 5vs19   -456.15204 237.9654 -1.91688408 0.1356202
## 5vs20   -307.15204 237.9654 -1.29074257 0.3415321
## 5vs21     44.84796 237.9654  0.18846423 0.9286446
## 5vs29    345.53982 237.9654  1.45205923 0.2794936
## 5vs30    373.53982 237.9654  1.56972341 0.2374389
## 5vs31    -17.46018 237.9654 -0.07337277 0.9676827
## 5vs32    302.53982 237.9654  1.27136068 0.3489247
## 5vs33   -206.46018 237.9654 -0.86760597 0.5362566
# As mesmas comparações múltiplas.
results_mm0 <- wzRfun::apmc(L,
                            model = mm0,
                            focus = "linh",
                            test = "fdr")
results_mm0
##    linh       fit       lwr      upr      cld
## 1     1 1840.9000 1729.3728 1952.427       ej
## 2     2 1598.3000 1486.7728 1709.827       kp
## 3     3 1772.7000 1661.1728 1884.227     dghj
## 4     4 1983.2000 1871.6728 2094.727     bcef
## 5     5 1507.7033 1175.5469 1839.860     jkpq
## 6     6 1236.7033  904.5469 1568.860      npr
## 7     7 1194.7033  862.5469 1526.860       pr
## 8     8 1683.7033 1351.5469 2015.860    ejkpq
## 9     9  752.7033  420.5469 1084.860        r
## 10   17 1712.8553 1380.6990 2045.012    ejkop
## 11   18 1682.8553 1350.6990 2015.012    ejkpq
## 12   19 1963.8553 1631.6990 2296.012    bcejk
## 13   20 1814.8553 1482.6990 2147.012 bceijklm
## 14   21 1462.8553 1130.6990 1795.012     jkpq
## 15   29 1162.1635  830.0071 1494.320      oqr
## 16   30 1134.1635  802.0071 1466.320       qr
## 17   31 1525.1635 1193.0071 1857.320     jkpq
## 18   32 1205.1635  873.0071 1537.320       pr
## 19   33 1714.1635 1382.0071 2046.320     ejkp
## 20   41 1481.2601 1149.1038 1813.416     jkpq
## 21   42 1343.2601 1011.1038 1675.416     lnpq
## 22   43 1200.2601  868.1038 1532.416       pr
## 23   44 1508.2601 1176.1038 1840.416     jkpq
## 24   45 1259.2601  927.1038 1591.416     mnpr
## 25   53 1853.9407 1521.7843 2186.097  bceijkl
## 26   54 1192.9407  860.7843 1525.097       pr
## 27   55 1223.9407  891.7843 1556.097      npr
## 28   56 1489.9407 1157.7843 1822.097     jkpq
## 29   57 1483.9407 1151.7843 1816.097     jkpq
## 30   65 1247.5433  915.3869 1579.700     mnpr
## 31   66 1514.5433 1182.3869 1846.700     jkpq
## 32   67 1382.5433 1050.3869 1714.700    hinpq
## 33   68 1554.5433 1222.3869 1886.700     jkpq
## 34   69 1924.5433 1592.3869 2256.700    bcejk
## 35   77 1820.5744 1488.4180 2152.731 bceijklm
## 36   78 2296.5744 1964.4180 2628.731       ab
## 37   79 2588.5744 2256.4180 2920.731        a
## 38   80 2148.5744 1816.4180 2480.731      ade
## 39   81 1747.5744 1415.4180 2079.731    cejkp
## 40   89 1959.3856 1627.2293 2291.542   bceijk
## 41   90 1184.3856  852.2293 1516.542       pr
## 42   91 1233.3856  901.2293 1565.542      npr
## 43   92 1177.3856  845.2293 1509.542       pr
## 44   93 1457.3856 1125.2293 1789.542     jkpq
## 45  101 1427.0193 1094.8629 1759.176     jkpq
## 46  102 1879.0193 1546.8629 2211.176  bceijkl
## 47  103 1873.0193 1540.8629 2205.176  bceijkl
## 48  104 1445.0193 1112.8629 1777.176     jkpq
## 49  105 1797.0193 1464.8629 2129.176   bcejkn
## 50  113 2136.5546 1804.3982 2468.711      ade
## 51  114 1406.5546 1074.3982 1738.711     gkpq
## 52  115 2312.5546 1980.3982 2644.711       ac
## 53  116 1561.5546 1229.3982 1893.711    fjkpq
## 54  117 2307.5546 1975.3982 2639.711       ac
# Gráfico de segmentos para as estimativas intervalares.
ggplot(data = results_mm0,
       mapping = aes(x = fit, y = reorder(linh, fit))) +
    geom_point() +
    geom_errorbarh(mapping = aes(xmin = lwr, xmax = upr),
                   height = 0) +
    geom_label(mapping = aes(
                   x = min(lwr),
                   label = sprintf("%0.0f %s", fit, cld)),
               label.padding = unit(0.15, "lines"),
               fill = "black",
               colour = "white",
               size = 3,
               nudge_x = -80,
               hjust = 0,
               vjust = 0.5) +
    labs(x = "Produção",
         y = "Linhagens")


Manual de Planejamento e Análise de Experimentos com R
Walmes Marques Zeviani