Curso de estatística experimental com aplicações em R

12 à 14 de Novembro de 2014 - Manaus - AM
Prof. Dr. Walmes M. Zeviani
Embrapa Amazônia Ocidental
Lab. de Estatística e Geoinformação - LEG
Departamento de Estatística - UFPR

Análise de VCU de soja

##-----------------------------------------------------------------------------
## Definições da sessão.

## Lista de pacotes a serem usados na sessão.
pkg <- c("lattice", "latticeExtra", "doBy", "multcomp", "lme4", "plyr",
         "gridExtra", "aod", "wzRfun")
sapply(pkg, require, character.only=TRUE)
##      lattice latticeExtra         doBy     multcomp         lme4         plyr 
##         TRUE         TRUE         TRUE         TRUE         TRUE         TRUE 
##    gridExtra          aod       wzRfun 
##         TRUE         TRUE         TRUE
sessionInfo()
## R version 3.1.1 (2014-07-10)
## Platform: i686-pc-linux-gnu (32-bit)
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=pt_BR.UTF-8       
##  [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=pt_BR.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=pt_BR.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
## [10] LC_TELEPHONE=C             LC_MEASUREMENT=pt_BR.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] grid      methods   splines   stats     graphics  grDevices utils     datasets 
## [9] base     
## 
## other attached packages:
##  [1] wzRfun_0.3          aod_1.3             gridExtra_0.9.1     plyr_1.8.1         
##  [5] lme4_1.1-7          Rcpp_0.11.3         Matrix_1.1-4        multcomp_1.3-7     
##  [9] TH.data_1.0-3       mvtnorm_0.9-9997    doBy_4.5-11         MASS_7.3-34        
## [13] survival_2.37-7     latticeExtra_0.6-26 RColorBrewer_1.0-5  lattice_0.20-29    
## [17] rmarkdown_0.3.3     knitr_1.7          
## 
## loaded via a namespace (and not attached):
##  [1] digest_0.6.4    evaluate_0.5.5  formatR_1.0     htmltools_0.2.6 minqa_1.2.3    
##  [6] nlme_3.1-117    nloptr_1.0.4    sandwich_2.3-0  stringr_0.6.2   tools_3.1.1    
## [11] yaml_2.1.13     zoo_1.7-10
trellis.device(color=FALSE)
##-----------------------------------------------------------------------------
## Leitura dos dados.

da <- read.table("http://www.leg.ufpr.br/~walmes/data/grupoexperimentos.txt",
                 header=TRUE, sep="\t", na.string=".")
str(da)
## 'data.frame':    300 obs. of  11 variables:
##  $ local: Factor w/ 4 levels "CPAO-DDOS","MARAC",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ gen  : Factor w/ 25 levels "BMX MAGNA RR",..: 15 15 15 16 16 16 25 25 25 9 ...
##  $ trat : int  1 1 1 2 2 2 3 3 3 4 ...
##  $ bl   : int  1 2 3 1 2 3 1 2 3 1 ...
##  $ df   : int  34 35 35 44 44 44 36 36 36 37 ...
##  $ dm   : int  101 98 99 102 104 105 97 98 99 98 ...
##  $ aca  : num  1 2 1 1 1 1 1 1 1 1 ...
##  $ ap   : int  91 98 96 105 95 91 81 87 84 75 ...
##  $ avag : int  13 16 15 15 12 13 14 16 14 14 ...
##  $ rend : num  2444 2737 2948 2398 2579 ...
##  $ p100 : num  11.2 11.3 11.2 10.2 11.2 ...
##-----------------------------------------------------------------------------
## Editar.

da <- transform(da,
                bl=factor(bl),
                blin=interaction(bl, local, drop=TRUE))
str(da)
## 'data.frame':    300 obs. of  12 variables:
##  $ local: Factor w/ 4 levels "CPAO-DDOS","MARAC",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ gen  : Factor w/ 25 levels "BMX MAGNA RR",..: 15 15 15 16 16 16 25 25 25 9 ...
##  $ trat : int  1 1 1 2 2 2 3 3 3 4 ...
##  $ bl   : Factor w/ 3 levels "1","2","3": 1 2 3 1 2 3 1 2 3 1 ...
##  $ df   : int  34 35 35 44 44 44 36 36 36 37 ...
##  $ dm   : int  101 98 99 102 104 105 97 98 99 98 ...
##  $ aca  : num  1 2 1 1 1 1 1 1 1 1 ...
##  $ ap   : int  91 98 96 105 95 91 81 87 84 75 ...
##  $ avag : int  13 16 15 15 12 13 14 16 14 14 ...
##  $ rend : num  2444 2737 2948 2398 2579 ...
##  $ p100 : num  11.2 11.3 11.2 10.2 11.2 ...
##  $ blin : Factor w/ 12 levels "1.CPAO-DDOS",..: 1 2 3 1 2 3 1 2 3 1 ...
sum(is.na(da$rend))
## [1] 11
da <- subset(da, !is.na(rend), select=c("local","gen","blin","rend"))
str(da)
## 'data.frame':    289 obs. of  4 variables:
##  $ local: Factor w/ 4 levels "CPAO-DDOS","MARAC",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ gen  : Factor w/ 25 levels "BMX MAGNA RR",..: 15 15 15 16 16 25 25 25 9 9 ...
##  $ blin : Factor w/ 12 levels "1.CPAO-DDOS",..: 1 2 3 1 2 1 2 3 1 2 ...
##  $ rend : num  2444 2737 2948 2398 2579 ...
## Nos níveis dos fatores não pode ter nome com traço, dá problema na
## cld(). Trocar por espaço.
levels(da$gen) <- gsub("-", " ", levels(da$gen))
levels(da$local) <- gsub("-", " ", levels(da$local))

levels(da$gen)
##  [1] "BMX MAGNA RR"    "BMX POTÊNCIA RR" "BR 01 25656"     "BR 02 04844"    
##  [5] "BR 02 22425"     "BR 02 68661"     "BR 02 72914"     "BR 02 78838"    
##  [9] "BRS 239"         "BRS 243 RR"      "BRS 246 RR"      "BRS 255 RR"     
## [13] "BRS 268"         "BRS 282"         "BRS 284"         "BRS 285"        
## [17] "BRS 291 RR"      "BRS 292 RR"      "BRS 294 RR"      "BRS Favorita RR"
## [21] "CD 202"          "Embrapa 48"      "M SOY 7908 RR"   "NK 7059 RR"     
## [25] "Vmax"
levels(da$local)
## [1] "CPAO DDOS" "MARAC"     "NAV"       "SIDROL"
##-----------------------------------------------------------------------------
## Layout.

x <- xtabs(~local+gen, data=da)
## dimnames(x) <- NULL
mosaicplot(x, off=10, las=4)

t(x)
##                  local
## gen               CPAO DDOS MARAC NAV SIDROL
##   BMX MAGNA RR            3     3   3      3
##   BMX POTÊNCIA RR         3     3   3      3
##   BR 01 25656             3     3   3      3
##   BR 02 04844             3     2   3      3
##   BR 02 22425             3     3   3      3
##   BR 02 68661             3     3   3      3
##   BR 02 72914             2     3   3      3
##   BR 02 78838             3     3   3      3
##   BRS 239                 3     2   3      3
##   BRS 243 RR              3     3   3      3
##   BRS 246 RR              2     3   3      3
##   BRS 255 RR              3     3   3      3
##   BRS 268                 3     3   2      3
##   BRS 282                 3     3   3      3
##   BRS 284                 3     3   2      3
##   BRS 285                 2     3   3      3
##   BRS 291 RR              3     2   3      3
##   BRS 292 RR              3     3   3      3
##   BRS 294 RR              3     3   3      3
##   BRS Favorita RR         3     3   3      3
##   CD 202                  3     3   2      3
##   Embrapa 48              3     3   3      3
##   M SOY 7908 RR           2     3   3      3
##   NK 7059 RR              3     3   3      3
##   Vmax                    3     3   2      3
##-----------------------------------------------------------------------------
## Ver.

xyplot(rend~gen|local, data=da, as.table=TRUE)

##-----------------------------------------------------------------------------
## Ajuste do modelo que considera apenas o efeito de genótipo como
## fixo, os demais e interações são aleatórios.
## * fixo: gen;
## * aleatório: local, bl dentro de local e local interação com gen.

## da$y <- sqrt(da$rend)
## da$y <- log(da$rend)
da$y <- da$rend
m0 <- lmer(y~gen+(1|local)+(1|blin)+(1|local:gen),
           data=da, REML=FALSE)
summary(m0)
## Linear mixed model fit by maximum likelihood  ['lmerMod']
## Formula: y ~ gen + (1 | local) + (1 | blin) + (1 | local:gen)
##    Data: da
## 
##      AIC      BIC   logLik deviance df.resid 
##   4442.2   4548.5  -2192.1   4384.2      260 
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.62640 -0.55572 -0.04777  0.56096  2.71467 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  local:gen (Intercept) 130327   361.01  
##  blin      (Intercept)   2330    48.27  
##  local     (Intercept) 155226   393.99  
##  Residual              136231   369.09  
## Number of obs: 289, groups:  local:gen, 100; blin, 12; local, 4
## 
## Fixed effects:
##                    Estimate Std. Error t value
## (Intercept)         3647.90     287.98  12.667
## genBMX POTÊNCIA RR   188.90     296.43   0.637
## genBR 01 25656       -25.56     296.43  -0.086
## genBR 02 04844       300.87     298.63   1.008
## genBR 02 22425      -405.27     296.43  -1.367
## genBR 02 68661        69.29     296.43   0.234
## genBR 02 72914       182.88     298.63   0.612
## genBR 02 78838        25.39     296.43   0.086
## genBRS 239          -224.91     298.63  -0.753
## genBRS 243 RR       -278.74     296.43  -0.940
## genBRS 246 RR       -279.82     298.63  -0.937
## genBRS 255 RR       -117.83     296.43  -0.398
## genBRS 268          -334.47     298.63  -1.120
## genBRS 282          -567.89     296.43  -1.916
## genBRS 284          -124.14     298.63  -0.416
## genBRS 285          -231.22     298.63  -0.774
## genBRS 291 RR       -552.31     298.63  -1.849
## genBRS 292 RR       -382.38     296.43  -1.290
## genBRS 294 RR       -237.63     296.43  -0.802
## genBRS Favorita RR    20.83     296.43   0.070
## genCD 202           -619.81     298.63  -2.075
## genEmbrapa 48       -539.55     296.43  -1.820
## genM SOY 7908 RR    -125.79     298.63  -0.421
## genNK 7059 RR       -181.84     296.43  -0.613
## genVmax             -321.02     298.63  -1.075
## 
## Correlation matrix not shown by default, as p = 25 > 20.
## Use print(x, correlation=TRUE)  or
##   vcov(x)     if you need it
## Abandona a interação.
m1 <- update(m0, .~.-(1|local:gen), data=da)
anova(m0, m1)
## Data: da
## Models:
## m1: y ~ gen + (1 | local) + (1 | blin)
## m0: y ~ gen + (1 | local) + (1 | blin) + (1 | local:gen)
##    Df    AIC    BIC  logLik deviance  Chisq Chi Df Pr(>Chisq)    
## m1 28 4497.7 4600.4 -2220.9   4441.7                             
## m0 29 4442.2 4548.5 -2192.1   4384.2 57.554      1  3.289e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Existe interação local:gen.

## Predição dos efeitos aleatórios.
lapply(ranef(m0), c)
## $`local:gen`
## $`local:gen`$`(Intercept)`
##   [1]  -12.111578 -312.990352 -100.397978 -313.796292  216.048861  103.478109    7.843113
##   [8] -151.404080  106.545779  -56.593443 -119.331095 -224.648333  104.150112  466.176150
##  [15] -188.230727 -246.795215    7.630458 -211.662276  -61.260587 -366.082826  282.577846
##  [22]  206.646593 -256.913765  326.162441  326.883365 -137.756255 -352.994910  204.367912
##  [29]  604.738880  621.788713  247.845524  742.951928  318.691933   35.043291 -166.014354
##  [36]  -99.038474 -267.695927 -345.010718 -250.213295  -30.507072 -313.334007 -236.467689
##  [43]  264.361603   -9.197814 -147.149871 -131.381642 -400.462955  307.600739 -256.039191
##  [50] -325.879159  165.535792  483.545556  353.434079 -348.748712 -597.196825 -104.512143
##  [57] -656.106767 -141.670077 -132.628808  254.425978  373.046973  711.019396   -1.065030
##  [64] -503.473252  -34.381493  230.395071  531.091461  158.146353   50.799564  319.029958
##  [71] -769.015755   43.068370 -427.198250   81.722484  321.334097  -15.667959  182.439706
##  [78] -457.404013   57.806124 -240.640749 -246.811490  -94.688274  -25.617777   -8.960262
##  [85]  -31.818181 -154.677404 -218.675136  241.925636  287.510397  253.119292  329.734150
##  [92] -302.254230 -210.845681   19.658837  194.202738  617.819550  150.747992  376.511277
##  [99] -151.845735 -322.338304
## 
## 
## $blin
## $blin$`(Intercept)`
##  [1]   0.5277995   9.5558317 -18.4517949  -3.2469247  10.9289698  -9.8587174 -46.1611695
##  [8]   6.6619318  45.9459368   0.1164028 -13.4596256  17.4413597
## 
## 
## $local
## $local$`(Intercept)`
## [1] -557.5040 -145.0143  429.4921  273.0262
##-----------------------------------------------------------------------------
## Teste para os termos de efeito fixo.

anova(m0)
## Analysis of Variance Table
##     Df  Sum Sq Mean Sq F value
## gen 24 4527370  188640  1.3847
## Não tem p-valor! É de propósito. Douglas Bates não concorda que o
## procedimento adequado para ser avaliar a estatística F seja por meio
## de ajustes no número de graus de liberdade do denominador. Para mais
## detalhes leia:
## https://stat.ethz.ch/pipermail/r-help/2006-May/094765.html

## Alternativas (em order de recomendação):
## 1. Teste de razão de verossimilhanças entre modelos aninhados (um com
##    outro sem o termo fixo de interesse, usar REML=FALSE).
## 2. Teste de Wald (inferência aproximada, pacote aod).

V <- vcov(m0)
b <- fixef(m0)

nobars(formula(m0))
## y ~ gen
Terms <- which(attr(m0@pp$X, "assign")==1)

## Chi-quadrado de Wald (baseado na aproximação quadrática da
## verossimilhança).
wt <- wald.test(Sigma=V, b=b, Terms=Terms)
wt
## Wald test:
## ----------
## 
## Chi-squared test:
## X2 = 33.2, df = 24, P(> X2) = 0.099
## Chi-quadrado da razão de verossimilhanças (não baseado em aproximação
## de função, melhor opção).
m1 <- update(m0, .~.-gen)
anova(m0, m1)
## Data: da
## Models:
## m1: y ~ (1 | local) + (1 | blin) + (1 | local:gen)
## m0: y ~ gen + (1 | local) + (1 | blin) + (1 | local:gen)
##    Df    AIC    BIC  logLik deviance  Chisq Chi Df Pr(>Chisq)
## m1  5 4422.9 4441.3 -2206.5   4412.9                         
## m0 29 4442.2 4548.5 -2192.1   4384.2 28.756     24     0.2294
##-----------------------------------------------------------------------------
## Diagnóstico.

r <- residuals(m0, type="pearson")
f <- fitted(m0)
bec <- unlist(ranef(m0)[1])
beb <- unlist(ranef(m0)[2])
be <- unlist(ranef(m0)[3])

xyplot(r~f, type=c("p", "smooth"))

xyplot(sqrt(abs(r))~f, type=c("p", "smooth"))

grid.arrange(qqmath(r),
             qqmath(bec),
             qqmath(beb),
             qqmath(be),
             nrow=2)

qqmath(~r|da$local)

##-----------------------------------------------------------------------------
## Médias ajustadas.

## Formula só da parte de efeito fixo.
f <- nobars(formula(m0))
X <- LSmatrix(lm(f, da), effect=c("gen"))
rownames(X) <- levels(da$gen)

## Estimativas das médias.
summary(glht(m0, linfct=X), test=adjusted(type="none"))
## 
##   Simultaneous Tests for General Linear Hypotheses
## 
## Fit: lmer(formula = y ~ gen + (1 | local) + (1 | blin) + (1 | local:gen), 
##     data = da, REML = FALSE)
## 
## Linear Hypotheses:
##                      Estimate Std. Error z value Pr(>|z|)    
## BMX MAGNA RR == 0      3647.9      288.0   12.67   <2e-16 ***
## BMX POTÊNCIA RR == 0   3836.8      288.0   13.32   <2e-16 ***
## BR 01 25656 == 0       3622.3      288.0   12.58   <2e-16 ***
## BR 02 04844 == 0       3948.8      290.3   13.61   <2e-16 ***
## BR 02 22425 == 0       3242.6      288.0   11.26   <2e-16 ***
## BR 02 68661 == 0       3717.2      288.0   12.91   <2e-16 ***
## BR 02 72914 == 0       3830.8      290.3   13.20   <2e-16 ***
## BR 02 78838 == 0       3673.3      288.0   12.76   <2e-16 ***
## BRS 239 == 0           3423.0      290.3   11.79   <2e-16 ***
## BRS 243 RR == 0        3369.2      288.0   11.70   <2e-16 ***
## BRS 246 RR == 0        3368.1      290.3   11.60   <2e-16 ***
## BRS 255 RR == 0        3530.1      288.0   12.26   <2e-16 ***
## BRS 268 == 0           3313.4      290.3   11.42   <2e-16 ***
## BRS 282 == 0           3080.0      288.0   10.70   <2e-16 ***
## BRS 284 == 0           3523.8      290.3   12.14   <2e-16 ***
## BRS 285 == 0           3416.7      290.3   11.77   <2e-16 ***
## BRS 291 RR == 0        3095.6      290.3   10.66   <2e-16 ***
## BRS 292 RR == 0        3265.5      288.0   11.34   <2e-16 ***
## BRS 294 RR == 0        3410.3      288.0   11.84   <2e-16 ***
## BRS Favorita RR == 0   3668.7      288.0   12.74   <2e-16 ***
## CD 202 == 0            3028.1      290.3   10.43   <2e-16 ***
## Embrapa 48 == 0        3108.3      288.0   10.79   <2e-16 ***
## M SOY 7908 RR == 0     3522.1      290.3   12.13   <2e-16 ***
## NK 7059 RR == 0        3466.1      288.0   12.04   <2e-16 ***
## Vmax == 0              3326.9      290.3   11.46   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- none method)
## Contraste.
Xc <- apc(X)
dim(Xc)
## [1] 300  25
g <- summary(glht(m0, linfct=Xc), test=adjusted(type="fdr")); g
## 
##   Simultaneous Tests for General Linear Hypotheses
## 
## Fit: lmer(formula = y ~ gen + (1 | local) + (1 | blin) + (1 | local:gen), 
##     data = da, REML = FALSE)
## 
## Linear Hypotheses:
##                                      Estimate Std. Error z value Pr(>|z|)
## BMX MAGNA RR-BMX POTÊNCIA RR == 0    -188.898    296.426  -0.637    0.832
## BMX MAGNA RR-BR 01 25656 == 0          25.562    296.426   0.086    0.977
## BMX MAGNA RR-BR 02 04844 == 0        -300.872    298.632  -1.008    0.725
## BMX MAGNA RR-BR 02 22425 == 0         405.272    296.426   1.367    0.630
## BMX MAGNA RR-BR 02 68661 == 0         -69.288    296.426  -0.234    0.944
## BMX MAGNA RR-BR 02 72914 == 0        -182.877    298.632  -0.612    0.840
## BMX MAGNA RR-BR 02 78838 == 0         -25.387    296.426  -0.086    0.977
## BMX MAGNA RR-BRS 239 == 0             224.908    298.632   0.753    0.806
## BMX MAGNA RR-BRS 243 RR == 0          278.736    296.426   0.940    0.738
## BMX MAGNA RR-BRS 246 RR == 0          279.815    298.632   0.937    0.738
## BMX MAGNA RR-BRS 255 RR == 0          117.835    296.426   0.398    0.892
## BMX MAGNA RR-BRS 268 == 0             334.474    298.632   1.120    0.725
## BMX MAGNA RR-BRS 282 == 0             567.886    296.426   1.916    0.476
## BMX MAGNA RR-BRS 284 == 0             124.142    298.633   0.416    0.892
## BMX MAGNA RR-BRS 285 == 0             231.222    298.632   0.774    0.798
## BMX MAGNA RR-BRS 291 RR == 0          552.311    298.632   1.849    0.508
## BMX MAGNA RR-BRS 292 RR == 0          382.376    296.426   1.290    0.661
## BMX MAGNA RR-BRS 294 RR == 0          237.626    296.426   0.802    0.788
## BMX MAGNA RR-BRS Favorita RR == 0     -20.830    296.426  -0.070    0.983
## BMX MAGNA RR-CD 202 == 0              619.806    298.633   2.075    0.476
## BMX MAGNA RR-Embrapa 48 == 0          539.554    296.426   1.820    0.515
## BMX MAGNA RR-M SOY 7908 RR == 0       125.791    298.632   0.421    0.892
## BMX MAGNA RR-NK 7059 RR == 0          181.837    296.426   0.613    0.840
## BMX MAGNA RR-Vmax == 0                321.022    298.633   1.075    0.725
## BMX POTÊNCIA RR-BR 01 25656 == 0      214.460    296.426   0.723    0.818
## BMX POTÊNCIA RR-BR 02 04844 == 0     -111.973    298.632  -0.375    0.892
## BMX POTÊNCIA RR-BR 02 22425 == 0      594.171    296.426   2.004    0.476
## BMX POTÊNCIA RR-BR 02 68661 == 0      119.610    296.426   0.404    0.892
## BMX POTÊNCIA RR-BR 02 72914 == 0        6.021    298.632   0.020    0.994
## BMX POTÊNCIA RR-BR 02 78838 == 0      163.512    296.426   0.552    0.858
## BMX POTÊNCIA RR-BRS 239 == 0          413.807    298.632   1.386    0.630
## BMX POTÊNCIA RR-BRS 243 RR == 0       467.634    296.426   1.578    0.624
## BMX POTÊNCIA RR-BRS 246 RR == 0       468.713    298.632   1.570    0.624
## BMX POTÊNCIA RR-BRS 255 RR == 0       306.733    296.426   1.035    0.725
## BMX POTÊNCIA RR-BRS 268 == 0          523.373    298.632   1.753    0.537
## BMX POTÊNCIA RR-BRS 282 == 0          756.784    296.426   2.553    0.389
## BMX POTÊNCIA RR-BRS 284 == 0          313.040    298.633   1.048    0.725
## BMX POTÊNCIA RR-BRS 285 == 0          420.120    298.632   1.407    0.630
## BMX POTÊNCIA RR-BRS 291 RR == 0       741.209    298.632   2.482    0.389
## BMX POTÊNCIA RR-BRS 292 RR == 0       571.274    296.426   1.927    0.476
## BMX POTÊNCIA RR-BRS 294 RR == 0       426.524    296.426   1.439    0.630
## BMX POTÊNCIA RR-BRS Favorita RR == 0  168.068    296.426   0.567    0.858
## BMX POTÊNCIA RR-CD 202 == 0           808.704    298.633   2.708    0.381
## BMX POTÊNCIA RR-Embrapa 48 == 0       728.452    296.426   2.457    0.389
## BMX POTÊNCIA RR-M SOY 7908 RR == 0    314.689    298.632   1.054    0.725
## BMX POTÊNCIA RR-NK 7059 RR == 0       370.735    296.426   1.251    0.688
## BMX POTÊNCIA RR-Vmax == 0             509.920    298.633   1.708    0.548
## BR 01 25656-BR 02 04844 == 0         -326.433    298.632  -1.093    0.725
## BR 01 25656-BR 02 22425 == 0          379.711    296.426   1.281    0.661
## BR 01 25656-BR 02 68661 == 0          -94.850    296.426  -0.320    0.892
## BR 01 25656-BR 02 72914 == 0         -208.439    298.632  -0.698    0.818
## BR 01 25656-BR 02 78838 == 0          -50.948    296.426  -0.172    0.945
## BR 01 25656-BRS 239 == 0              199.347    298.632   0.668    0.822
## BR 01 25656-BRS 243 RR == 0           253.174    296.426   0.854    0.762
## BR 01 25656-BRS 246 RR == 0           254.253    298.632   0.851    0.762
## BR 01 25656-BRS 255 RR == 0            92.273    296.426   0.311    0.896
## BR 01 25656-BRS 268 == 0              308.913    298.632   1.034    0.725
## BR 01 25656-BRS 282 == 0              542.324    296.426   1.830    0.515
## BR 01 25656-BRS 284 == 0               98.580    298.633   0.330    0.892
## BR 01 25656-BRS 285 == 0              205.660    298.632   0.689    0.818
## BR 01 25656-BRS 291 RR == 0           526.749    298.632   1.764    0.537
## BR 01 25656-BRS 292 RR == 0           356.814    296.426   1.204    0.707
## BR 01 25656-BRS 294 RR == 0           212.064    296.426   0.715    0.818
## BR 01 25656-BRS Favorita RR == 0      -46.392    296.426  -0.157    0.945
## BR 01 25656-CD 202 == 0               594.244    298.633   1.990    0.476
## BR 01 25656-Embrapa 48 == 0           513.992    296.426   1.734    0.541
## BR 01 25656-M SOY 7908 RR == 0        100.229    298.632   0.336    0.892
## BR 01 25656-NK 7059 RR == 0           156.275    296.426   0.527    0.858
## BR 01 25656-Vmax == 0                 295.460    298.633   0.989    0.732
## BR 02 04844-BR 02 22425 == 0          706.144    298.632   2.365    0.417
## BR 02 04844-BR 02 68661 == 0          231.583    298.632   0.775    0.798
## BR 02 04844-BR 02 72914 == 0          117.995    300.827   0.392    0.892
## BR 02 04844-BR 02 78838 == 0          275.485    298.632   0.922    0.747
## BR 02 04844-BRS 239 == 0              525.780    300.831   1.748    0.537
## BR 02 04844-BRS 243 RR == 0           579.608    298.632   1.941    0.476
## BR 02 04844-BRS 246 RR == 0           580.687    300.827   1.930    0.476
## BR 02 04844-BRS 255 RR == 0           418.707    298.632   1.402    0.630
## BR 02 04844-BRS 268 == 0              635.346    300.826   2.112    0.476
## BR 02 04844-BRS 282 == 0              868.758    298.632   2.909    0.367
## BR 02 04844-BRS 284 == 0              425.013    300.827   1.413    0.630
## BR 02 04844-BRS 285 == 0              532.094    300.827   1.769    0.537
## BR 02 04844-BRS 291 RR == 0           853.183    300.831   2.836    0.367
## BR 02 04844-BRS 292 RR == 0           683.248    298.632   2.288    0.443
## BR 02 04844-BRS 294 RR == 0           538.498    298.632   1.803    0.522
## BR 02 04844-BRS Favorita RR == 0      280.042    298.632   0.938    0.738
## BR 02 04844-CD 202 == 0               920.677    300.827   3.060    0.367
## BR 02 04844-Embrapa 48 == 0           840.426    298.632   2.814    0.367
## BR 02 04844-M SOY 7908 RR == 0        426.663    300.827   1.418    0.630
## BR 02 04844-NK 7059 RR == 0           482.708    298.632   1.616    0.600
## BR 02 04844-Vmax == 0                 621.894    300.827   2.067    0.476
## BR 02 22425-BR 02 68661 == 0         -474.561    296.426  -1.601    0.608
## BR 02 22425-BR 02 72914 == 0         -588.149    298.632  -1.969    0.476
## BR 02 22425-BR 02 78838 == 0         -430.659    296.426  -1.453    0.630
## BR 02 22425-BRS 239 == 0             -180.364    298.632  -0.604    0.844
## BR 02 22425-BRS 243 RR == 0          -126.537    296.426  -0.427    0.892
## BR 02 22425-BRS 246 RR == 0          -125.457    298.632  -0.420    0.892
## BR 02 22425-BRS 255 RR == 0          -287.438    296.426  -0.970    0.738
## BR 02 22425-BRS 268 == 0              -70.798    298.632  -0.237    0.944
## BR 02 22425-BRS 282 == 0              162.613    296.426   0.549    0.858
## BR 02 22425-BRS 284 == 0             -281.131    298.633  -0.941    0.738
## BR 02 22425-BRS 285 == 0             -174.051    298.632  -0.583    0.858
## BR 02 22425-BRS 291 RR == 0           147.038    298.632   0.492    0.858
## BR 02 22425-BRS 292 RR == 0           -22.897    296.426  -0.077    0.981
## BR 02 22425-BRS 294 RR == 0          -167.647    296.426  -0.566    0.858
## BR 02 22425-BRS Favorita RR == 0     -426.102    296.426  -1.437    0.630
## BR 02 22425-CD 202 == 0               214.533    298.633   0.718    0.818
## BR 02 22425-Embrapa 48 == 0           134.282    296.426   0.453    0.875
## BR 02 22425-M SOY 7908 RR == 0       -279.482    298.632  -0.936    0.738
## BR 02 22425-NK 7059 RR == 0          -223.436    296.426  -0.754    0.806
## BR 02 22425-Vmax == 0                 -84.250    298.633  -0.282    0.914
## BR 02 68661-BR 02 72914 == 0         -113.589    298.632  -0.380    0.892
## BR 02 68661-BR 02 78838 == 0           43.902    296.426   0.148    0.945
## BR 02 68661-BRS 239 == 0              294.197    298.632   0.985    0.732
## BR 02 68661-BRS 243 RR == 0           348.024    296.426   1.174    0.725
## BR 02 68661-BRS 246 RR == 0           349.103    298.632   1.169    0.725
## BR 02 68661-BRS 255 RR == 0           187.123    296.426   0.631    0.833
## BR 02 68661-BRS 268 == 0              403.763    298.632   1.352    0.630
## BR 02 68661-BRS 282 == 0              637.174    296.426   2.150    0.476
## BR 02 68661-BRS 284 == 0              193.430    298.633   0.648    0.825
## BR 02 68661-BRS 285 == 0              300.510    298.632   1.006    0.725
## BR 02 68661-BRS 291 RR == 0           621.599    298.632   2.081    0.476
## BR 02 68661-BRS 292 RR == 0           451.664    296.426   1.524    0.630
## BR 02 68661-BRS 294 RR == 0           306.914    296.426   1.035    0.725
## BR 02 68661-BRS Favorita RR == 0       48.458    296.426   0.163    0.945
## BR 02 68661-CD 202 == 0               689.094    298.633   2.307    0.443
## BR 02 68661-Embrapa 48 == 0           608.842    296.426   2.054    0.476
## BR 02 68661-M SOY 7908 RR == 0        195.079    298.632   0.653    0.825
## BR 02 68661-NK 7059 RR == 0           251.125    296.426   0.847    0.762
## BR 02 68661-Vmax == 0                 390.310    298.633   1.307    0.661
## BR 02 72914-BR 02 78838 == 0          157.490    298.632   0.527    0.858
## BR 02 72914-BRS 239 == 0              407.785    300.827   1.356    0.630
## BR 02 72914-BRS 243 RR == 0           461.613    298.632   1.546    0.630
## BR 02 72914-BRS 246 RR == 0           462.692    300.832   1.538    0.630
## BR 02 72914-BRS 255 RR == 0           300.712    298.632   1.007    0.725
## BR 02 72914-BRS 268 == 0              517.351    300.827   1.720    0.546
## BR 02 72914-BRS 282 == 0              750.763    298.632   2.514    0.389
## BR 02 72914-BRS 284 == 0              307.019    300.828   1.021    0.725
## BR 02 72914-BRS 285 == 0              414.099    300.832   1.377    0.630
## BR 02 72914-BRS 291 RR == 0           735.188    300.827   2.444    0.389
## BR 02 72914-BRS 292 RR == 0           565.253    298.632   1.893    0.476
## BR 02 72914-BRS 294 RR == 0           420.503    298.632   1.408    0.630
## BR 02 72914-BRS Favorita RR == 0      162.047    298.632   0.543    0.858
## BR 02 72914-CD 202 == 0               802.683    300.828   2.668    0.381
## BR 02 72914-Embrapa 48 == 0           722.431    298.632   2.419    0.389
## BR 02 72914-M SOY 7908 RR == 0        308.668    300.759   1.026    0.725
## BR 02 72914-NK 7059 RR == 0           364.714    298.632   1.221    0.707
## BR 02 72914-Vmax == 0                 503.899    300.828   1.675    0.564
## BR 02 78838-BRS 239 == 0              250.295    298.632   0.838    0.763
## BR 02 78838-BRS 243 RR == 0           304.122    296.426   1.026    0.725
## BR 02 78838-BRS 246 RR == 0           305.202    298.632   1.022    0.725
## BR 02 78838-BRS 255 RR == 0           143.222    296.426   0.483    0.858
## BR 02 78838-BRS 268 == 0              359.861    298.632   1.205    0.707
## BR 02 78838-BRS 282 == 0              593.272    296.426   2.001    0.476
## BR 02 78838-BRS 284 == 0              149.528    298.633   0.501    0.858
## BR 02 78838-BRS 285 == 0              256.608    298.632   0.859    0.762
## BR 02 78838-BRS 291 RR == 0           577.697    298.632   1.934    0.476
## BR 02 78838-BRS 292 RR == 0           407.762    296.426   1.376    0.630
## BR 02 78838-BRS 294 RR == 0           263.012    296.426   0.887    0.762
## BR 02 78838-BRS Favorita RR == 0        4.557    296.426   0.015    0.994
## BR 02 78838-CD 202 == 0               645.192    298.633   2.160    0.476
## BR 02 78838-Embrapa 48 == 0           564.941    296.426   1.906    0.476
## BR 02 78838-M SOY 7908 RR == 0        151.178    298.632   0.506    0.858
## BR 02 78838-NK 7059 RR == 0           207.223    296.426   0.699    0.818
## BR 02 78838-Vmax == 0                 346.409    298.633   1.160    0.725
## BRS 239-BRS 243 RR == 0                53.828    298.632   0.180    0.945
## BRS 239-BRS 246 RR == 0                54.907    300.827   0.183    0.945
## BRS 239-BRS 255 RR == 0              -107.073    298.632  -0.359    0.892
## BRS 239-BRS 268 == 0                  109.566    300.826   0.364    0.892
## BRS 239-BRS 282 == 0                  342.978    298.632   1.148    0.725
## BRS 239-BRS 284 == 0                 -100.766    300.827  -0.335    0.892
## BRS 239-BRS 285 == 0                    6.314    300.827   0.021    0.994
## BRS 239-BRS 291 RR == 0               327.403    300.831   1.088    0.725
## BRS 239-BRS 292 RR == 0               157.468    298.632   0.527    0.858
## BRS 239-BRS 294 RR == 0                12.718    298.632   0.043    0.992
## BRS 239-BRS Favorita RR == 0         -245.738    298.632  -0.823    0.770
## BRS 239-CD 202 == 0                   394.898    300.827   1.313    0.661
## BRS 239-Embrapa 48 == 0               314.646    298.632   1.054    0.725
## BRS 239-M SOY 7908 RR == 0            -99.117    300.827  -0.329    0.892
## BRS 239-NK 7059 RR == 0               -43.072    298.632  -0.144    0.945
## BRS 239-Vmax == 0                      96.114    300.827   0.319    0.892
## BRS 243 RR-BRS 246 RR == 0              1.079    298.632   0.004    0.997
## BRS 243 RR-BRS 255 RR == 0           -160.901    296.426  -0.543    0.858
## BRS 243 RR-BRS 268 == 0                55.739    298.632   0.187    0.945
## BRS 243 RR-BRS 282 == 0               289.150    296.426   0.975    0.737
## BRS 243 RR-BRS 284 == 0              -154.594    298.633  -0.518    0.858
## BRS 243 RR-BRS 285 == 0               -47.514    298.632  -0.159    0.945
## BRS 243 RR-BRS 291 RR == 0            273.575    298.632   0.916    0.749
## BRS 243 RR-BRS 292 RR == 0            103.640    296.426   0.350    0.892
## BRS 243 RR-BRS 294 RR == 0            -41.110    296.426  -0.139    0.945
## BRS 243 RR-BRS Favorita RR == 0      -299.566    296.426  -1.011    0.725
## BRS 243 RR-CD 202 == 0                341.070    298.633   1.142    0.725
## BRS 243 RR-Embrapa 48 == 0            260.818    296.426   0.880    0.762
## BRS 243 RR-M SOY 7908 RR == 0        -152.945    298.632  -0.512    0.858
## BRS 243 RR-NK 7059 RR == 0            -96.899    296.426  -0.327    0.892
## BRS 243 RR-Vmax == 0                   42.286    298.633   0.142    0.945
## BRS 246 RR-BRS 255 RR == 0           -161.980    298.632  -0.542    0.858
## BRS 246 RR-BRS 268 == 0                54.659    300.827   0.182    0.945
## BRS 246 RR-BRS 282 == 0               288.071    298.632   0.965    0.738
## BRS 246 RR-BRS 284 == 0              -155.673    300.828  -0.517    0.858
## BRS 246 RR-BRS 285 == 0               -48.593    300.759  -0.162    0.945
## BRS 246 RR-BRS 291 RR == 0            272.496    300.827   0.906    0.755
## BRS 246 RR-BRS 292 RR == 0            102.561    298.632   0.343    0.892
## BRS 246 RR-BRS 294 RR == 0            -42.189    298.632  -0.141    0.945
## BRS 246 RR-BRS Favorita RR == 0      -300.645    298.632  -1.007    0.725
## BRS 246 RR-CD 202 == 0                339.991    300.828   1.130    0.725
## BRS 246 RR-Embrapa 48 == 0            259.739    298.632   0.870    0.762
## BRS 246 RR-M SOY 7908 RR == 0        -154.024    300.832  -0.512    0.858
## BRS 246 RR-NK 7059 RR == 0            -97.978    298.632  -0.328    0.892
## BRS 246 RR-Vmax == 0                   41.207    300.828   0.137    0.945
## BRS 255 RR-BRS 268 == 0               216.639    298.632   0.725    0.818
## BRS 255 RR-BRS 282 == 0               450.051    296.426   1.518    0.630
## BRS 255 RR-BRS 284 == 0                 6.307    298.633   0.021    0.994
## BRS 255 RR-BRS 285 == 0               113.387    298.632   0.380    0.892
## BRS 255 RR-BRS 291 RR == 0            434.476    298.632   1.455    0.630
## BRS 255 RR-BRS 292 RR == 0            264.541    296.426   0.892    0.762
## BRS 255 RR-BRS 294 RR == 0            119.791    296.426   0.404    0.892
## BRS 255 RR-BRS Favorita RR == 0      -138.665    296.426  -0.468    0.866
## BRS 255 RR-CD 202 == 0                501.971    298.633   1.681    0.564
## BRS 255 RR-Embrapa 48 == 0            421.719    296.426   1.423    0.630
## BRS 255 RR-M SOY 7908 RR == 0           7.956    298.632   0.027    0.994
## BRS 255 RR-NK 7059 RR == 0             64.002    296.426   0.216    0.945
## BRS 255 RR-Vmax == 0                  203.187    298.633   0.680    0.818
## BRS 268-BRS 282 == 0                  233.411    298.632   0.782    0.798
## BRS 268-BRS 284 == 0                 -210.333    300.832  -0.699    0.818
## BRS 268-BRS 285 == 0                 -103.253    300.827  -0.343    0.892
## BRS 268-BRS 291 RR == 0               217.836    300.826   0.724    0.818
## BRS 268-BRS 292 RR == 0                47.901    298.632   0.160    0.945
## BRS 268-BRS 294 RR == 0               -96.849    298.632  -0.324    0.892
## BRS 268-BRS Favorita RR == 0         -355.304    298.632  -1.190    0.717
## BRS 268-CD 202 == 0                   285.331    300.832   0.948    0.738
## BRS 268-Embrapa 48 == 0               205.080    298.632   0.687    0.818
## BRS 268-M SOY 7908 RR == 0           -208.684    300.827  -0.694    0.818
## BRS 268-NK 7059 RR == 0              -152.638    298.632  -0.511    0.858
## BRS 268-Vmax == 0                     -13.452    300.832  -0.045    0.992
## BRS 282-BRS 284 == 0                 -443.744    298.633  -1.486    0.630
## BRS 282-BRS 285 == 0                 -336.664    298.632  -1.127    0.725
## BRS 282-BRS 291 RR == 0               -15.575    298.632  -0.052    0.992
## BRS 282-BRS 292 RR == 0              -185.510    296.426  -0.626    0.835
## BRS 282-BRS 294 RR == 0              -330.260    296.426  -1.114    0.725
## BRS 282-BRS Favorita RR == 0         -588.716    296.426  -1.986    0.476
## BRS 282-CD 202 == 0                    51.920    298.633   0.174    0.945
## BRS 282-Embrapa 48 == 0               -28.332    296.426  -0.096    0.976
## BRS 282-M SOY 7908 RR == 0           -442.095    298.632  -1.480    0.630
## BRS 282-NK 7059 RR == 0              -386.049    296.426  -1.302    0.661
## BRS 282-Vmax == 0                    -246.864    298.633  -0.827    0.770
## BRS 284-BRS 285 == 0                  107.080    300.828   0.356    0.892
## BRS 284-BRS 291 RR == 0               428.169    300.827   1.423    0.630
## BRS 284-BRS 292 RR == 0               258.234    298.633   0.865    0.762
## BRS 284-BRS 294 RR == 0               113.484    298.633   0.380    0.892
## BRS 284-BRS Favorita RR == 0         -144.972    298.633  -0.485    0.858
## BRS 284-CD 202 == 0                   495.664    300.759   1.648    0.580
## BRS 284-Embrapa 48 == 0               415.412    298.633   1.391    0.630
## BRS 284-M SOY 7908 RR == 0              1.649    300.828   0.005    0.997
## BRS 284-NK 7059 RR == 0                57.695    298.633   0.193    0.945
## BRS 284-Vmax == 0                     196.880    300.759   0.655    0.825
## BRS 285-BRS 291 RR == 0               321.089    300.827   1.067    0.725
## BRS 285-BRS 292 RR == 0               151.154    298.632   0.506    0.858
## BRS 285-BRS 294 RR == 0                 6.404    298.632   0.021    0.994
## BRS 285-BRS Favorita RR == 0         -252.052    298.632  -0.844    0.762
## BRS 285-CD 202 == 0                   388.584    300.828   1.292    0.661
## BRS 285-Embrapa 48 == 0               308.332    298.632   1.032    0.725
## BRS 285-M SOY 7908 RR == 0           -105.431    300.832  -0.350    0.892
## BRS 285-NK 7059 RR == 0               -49.385    298.632  -0.165    0.945
## BRS 285-Vmax == 0                      89.800    300.828   0.299    0.904
## BRS 291 RR-BRS 292 RR == 0           -169.935    298.632  -0.569    0.858
## BRS 291 RR-BRS 294 RR == 0           -314.685    298.632  -1.054    0.725
## BRS 291 RR-BRS Favorita RR == 0      -573.141    298.632  -1.919    0.476
## BRS 291 RR-CD 202 == 0                 67.495    300.827   0.224    0.945
## BRS 291 RR-Embrapa 48 == 0            -12.757    298.632  -0.043    0.992
## BRS 291 RR-M SOY 7908 RR == 0        -426.520    300.827  -1.418    0.630
## BRS 291 RR-NK 7059 RR == 0           -370.474    298.632  -1.241    0.693
## BRS 291 RR-Vmax == 0                 -231.289    300.827  -0.769    0.799
## BRS 292 RR-BRS 294 RR == 0           -144.750    296.426  -0.488    0.858
## BRS 292 RR-BRS Favorita RR == 0      -403.206    296.426  -1.360    0.630
## BRS 292 RR-CD 202 == 0                237.430    298.633   0.795    0.790
## BRS 292 RR-Embrapa 48 == 0            157.178    296.426   0.530    0.858
## BRS 292 RR-M SOY 7908 RR == 0        -256.585    298.632  -0.859    0.762
## BRS 292 RR-NK 7059 RR == 0           -200.539    296.426  -0.677    0.818
## BRS 292 RR-Vmax == 0                  -61.354    298.633  -0.205    0.945
## BRS 294 RR-BRS Favorita RR == 0      -258.456    296.426  -0.872    0.762
## BRS 294 RR-CD 202 == 0                382.180    298.633   1.280    0.661
## BRS 294 RR-Embrapa 48 == 0            301.928    296.426   1.019    0.725
## BRS 294 RR-M SOY 7908 RR == 0        -111.835    298.632  -0.374    0.892
## BRS 294 RR-NK 7059 RR == 0            -55.789    296.426  -0.188    0.945
## BRS 294 RR-Vmax == 0                   83.396    298.633   0.279    0.914
## BRS Favorita RR-CD 202 == 0           640.636    298.633   2.145    0.476
## BRS Favorita RR-Embrapa 48 == 0       560.384    296.426   1.890    0.476
## BRS Favorita RR-M SOY 7908 RR == 0    146.621    298.632   0.491    0.858
## BRS Favorita RR-NK 7059 RR == 0       202.667    296.426   0.684    0.818
## BRS Favorita RR-Vmax == 0             341.852    298.633   1.145    0.725
## CD 202-Embrapa 48 == 0                -80.252    298.633  -0.269    0.920
## CD 202-M SOY 7908 RR == 0            -494.015    300.828  -1.642    0.580
## CD 202-NK 7059 RR == 0               -437.969    298.633  -1.467    0.630
## CD 202-Vmax == 0                     -298.784    300.759  -0.993    0.732
## Embrapa 48-M SOY 7908 RR == 0        -413.763    298.632  -1.386    0.630
## Embrapa 48-NK 7059 RR == 0           -357.718    296.426  -1.207    0.707
## Embrapa 48-Vmax == 0                 -218.532    298.633  -0.732    0.818
## M SOY 7908 RR-NK 7059 RR == 0          56.046    298.632   0.188    0.945
## M SOY 7908 RR-Vmax == 0               195.231    300.828   0.649    0.825
## NK 7059 RR-Vmax == 0                  139.185    298.633   0.466    0.866
## (Adjusted p values reported -- fdr method)
## Estimativas das médias com comparações.
## grid <- apmc(X=X, model=m0, focus="gen", test="bonferroni")
grid <- apmc(X=X, model=m0, focus="gen", test="fdr")
grid
##                gen estimate      lwr      upr cld
## 1     BMX MAGNA RR 3647.902 3083.463 4212.341   a
## 2  BMX POTÊNCIA RR 3836.800 3272.361 4401.239   a
## 3      BR 01 25656 3622.340 3057.901 4186.779   a
## 4      BR 02 04844 3948.773 3379.885 4517.661   a
## 5      BR 02 22425 3242.629 2678.190 3807.068   a
## 6      BR 02 68661 3717.190 3152.751 4281.629   a
## 7      BR 02 72914 3830.779 3261.890 4399.668   a
## 8      BR 02 78838 3673.288 3108.849 4237.727   a
## 9          BRS 239 3422.993 2854.105 3991.881   a
## 10      BRS 243 RR 3369.166 2804.727 3933.605   a
## 11      BRS 246 RR 3368.087 2799.198 3936.976   a
## 12      BRS 255 RR 3530.067 2965.628 4094.506   a
## 13         BRS 268 3313.427 2744.539 3882.315   a
## 14         BRS 282 3080.016 2515.577 3644.455   a
## 15         BRS 284 3523.760 2954.870 4092.650   a
## 16         BRS 285 3416.680 2847.791 3985.569   a
## 17      BRS 291 RR 3095.591 2526.703 3664.479   a
## 18      BRS 292 RR 3265.526 2701.087 3829.965   a
## 19      BRS 294 RR 3410.276 2845.837 3974.715   a
## 20 BRS Favorita RR 3668.732 3104.293 4233.171   a
## 21          CD 202 3028.096 2459.206 3596.986   a
## 22      Embrapa 48 3108.348 2543.908 3672.787   a
## 23   M SOY 7908 RR 3522.111 2953.222 4091.000   a
## 24      NK 7059 RR 3466.065 2901.626 4030.504   a
## 25            Vmax 3326.880 2757.990 3895.769   a
##-----------------------------------------------------------------------------
## Gráfico.

segplot(reorder(gen, estimate)~lwr+upr, centers=estimate,
        ylab="Cultivar de soja", xlab="Produtividade",
        data=grid, draw=FALSE, cld=grid$cld,
        panel=function(x, y, z, centers, subscripts, cld, ...){
            panel.segplot(x, y, z, centers=centers,
                          subscripts=subscripts, ...)
            panel.text(x=centers[subscripts], y=as.numeric(z)[subscripts],
                       labels=cld[subscripts], pos=4)
        })

##-----------------------------------------------------------------------------
## Para desdobrar a interação local:gen, tratar como efeito fixo.

formula(m0)
## y ~ gen + (1 | local) + (1 | blin) + (1 | local:gen)
m0 <- lmer(y~local*gen+(1|blin),
           data=da, REML=FALSE)

##-----------------------------------------------------------------------------
## Fazer o desdobramento dentro do primeiro local. Os demais seguem a
## mesma regra.

X <- LSmatrix(lm(nobars(formula(m0)), data=da), effect=c("local","gen"))
dim(X)
## [1] 100 100
L <- by(X, attr(X, "grid")$local, as.matrix)
L <- lapply(L, "rownames<-", levels(da$gen))
str(L)
## List of 4
##  $ CPAO DDOS: num [1:25, 1:100] 1 1 1 1 1 1 1 1 1 1 ...
##   ..- attr(*, "dimnames")=List of 2
##   .. ..$ : chr [1:25] "BMX MAGNA RR" "BMX POTÊNCIA RR" "BR 01 25656" "BR 02 04844" ...
##   .. ..$ : chr [1:100] "(Intercept)" "localMARAC" "localNAV" "localSIDROL" ...
##  $ MARAC    : num [1:25, 1:100] 1 1 1 1 1 1 1 1 1 1 ...
##   ..- attr(*, "dimnames")=List of 2
##   .. ..$ : chr [1:25] "BMX MAGNA RR" "BMX POTÊNCIA RR" "BR 01 25656" "BR 02 04844" ...
##   .. ..$ : chr [1:100] "(Intercept)" "localMARAC" "localNAV" "localSIDROL" ...
##  $ NAV      : num [1:25, 1:100] 1 1 1 1 1 1 1 1 1 1 ...
##   ..- attr(*, "dimnames")=List of 2
##   .. ..$ : chr [1:25] "BMX MAGNA RR" "BMX POTÊNCIA RR" "BR 01 25656" "BR 02 04844" ...
##   .. ..$ : chr [1:100] "(Intercept)" "localMARAC" "localNAV" "localSIDROL" ...
##  $ SIDROL   : num [1:25, 1:100] 1 1 1 1 1 1 1 1 1 1 ...
##   ..- attr(*, "dimnames")=List of 2
##   .. ..$ : chr [1:25] "BMX MAGNA RR" "BMX POTÊNCIA RR" "BR 01 25656" "BR 02 04844" ...
##   .. ..$ : chr [1:100] "(Intercept)" "localMARAC" "localNAV" "localSIDROL" ...
grid <- lapply(L, apmc, model=m0, focus="gen", test="fdr")
str(grid)
## List of 4
##  $ CPAO DDOS:'data.frame':   25 obs. of  5 variables:
##   ..$ gen     : Factor w/ 25 levels "BMX MAGNA RR",..: 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ estimate: num [1:25] 3071 2854 2927 2965 2974 ...
##   ..$ lwr     : num [1:25] 2731 2514 2586 2625 2633 ...
##   ..$ upr     : num [1:25] 3412 3195 3267 3306 3314 ...
##   ..$ cld     : chr [1:25] "ab" "ab" "ab" "ab" ...
##  $ MARAC    :'data.frame':   25 obs. of  5 variables:
##   ..$ gen     : Factor w/ 25 levels "BMX MAGNA RR",..: 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ estimate: num [1:25] 3316 3215 3752 4725 3935 ...
##   ..$ lwr     : num [1:25] 2976 2875 3412 4309 3595 ...
##   ..$ upr     : num [1:25] 3657 3556 4093 5142 4276 ...
##   ..$ cld     : chr [1:25] "cef" "efgi" "cdh" "a" ...
##  $ NAV      :'data.frame':   25 obs. of  5 variables:
##   ..$ gen     : Factor w/ 25 levels "BMX MAGNA RR",..: 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ estimate: num [1:25] 4303 4920 4531 3910 2869 ...
##   ..$ lwr     : num [1:25] 3962 4580 4190 3570 2529 ...
##   ..$ upr     : num [1:25] 4643 5261 4871 4251 3209 ...
##   ..$ cld     : chr [1:25] "cd" "a" "ac" "bdf" ...
##  $ SIDROL   :'data.frame':   25 obs. of  5 variables:
##   ..$ gen     : Factor w/ 25 levels "BMX MAGNA RR",..: 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ estimate: num [1:25] 3901 4357 3280 4301 3193 ...
##   ..$ lwr     : num [1:25] 3561 4017 2939 3961 2852 ...
##   ..$ upr     : num [1:25] 4242 4698 3620 4642 3533 ...
##   ..$ cld     : chr [1:25] "dfg" "f" "ac" "bf" ...
grid <- ldply(grid); names(grid)[1] <- "local"
grid <- equallevels(grid, da)
str(grid)
## 'data.frame':    100 obs. of  6 variables:
##  $ local   : Factor w/ 4 levels "CPAO DDOS","MARAC",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ gen     : Factor w/ 25 levels "BMX MAGNA RR",..: 1 2 3 4 5 6 7 8 9 10 ...
##  $ estimate: num  3071 2854 2927 2965 2974 ...
##  $ lwr     : num  2731 2514 2586 2625 2633 ...
##  $ upr     : num  3412 3195 3267 3306 3314 ...
##  $ cld     : chr  "ab" "ab" "ab" "ab" ...
##-----------------------------------------------------------------------------
## Gráfico.

segplot(gen~lwr+upr|local, centers=estimate,
        ylab="Genivar de arroz", xlab="Produtividade",
        data=grid, draw=FALSE, strip=FALSE, strip.left=TRUE,
        scales=list(
            y=list(relation="free", rot=0)),
        layout=c(2,NA))

##-----------------------------------------------------------------------------
## Truque para ordenar gen dentro dos locais no gráfico.

## Função que remove o texto antes do ponto separador.
yscale.components.dropend <- function(...){
  ans <- yscale.components.default(...)
  lab <- ans$left$labels$labels
  ans$left$labels$labels <- gsub("^.*\\.", "", lab)
  ans
}

## Número de gen em cada local.
ngen <- apply(xtabs(~local+gen, da), 1, function(i) sum(i>0))
ngen
## CPAO DDOS     MARAC       NAV    SIDROL 
##        25        25        25        25
grid$locgen <- with(grid, interaction(local, gen))

## Ordem original dos níveis do fator locgen.
on <- levels(grid$locgen)
neworder <- with(grid, order(local, estimate))

orderin <- by(grid, INDICE=grid$local,
              function(i){
                  as.character(i$locgen[order(i$estimate)])
              })

## Uma cópia do fator com ondem diferente dos níveis.
grid$locgen2 <- factor(grid$locgen, levels=unlist(orderin))

segplot(locgen2~lwr+upr|local, centers=estimate,
        ylab="Cultivar de soja", xlab="Produtividade",
        data=grid, draw=FALSE,
        scales=list(y=list(relation="free", rot=0, tck=0.5, cex=0.7)),
        yscale.components=yscale.components.dropend,
        between=list(y=0.2),
        layout=c(2,NA), as.table=TRUE)