Getting started

In this section, we will use the data in data_ge. For more information, please, see ?data_ge. Other data sets can be used provided that the following columns are in the dataset: environment, genotype, block/replicate and response variable(s).

The first step is to inspect the data with the function inspect().

Analysis of single experiments using mixed-models

The function gamem() may be used to analyze single experiments (one-way experiments) using a mixed-effect model according to the following model:

\[ y_{ij}= \mu + \alpha_i + \tau_j + \varepsilon_{ij} \] where \(y_{ij}\) is the value observed for the ith genotype in the jth replicate (i = 1, 2, … g; j = 1, 2, .., r); being g and r the number of genotypes and replicates, respectively; \(\alpha_i\) is the random effect of the ith genotype; \(\tau_j\) is the fixed effect of the jth replicate; and \(\varepsilon_{ij}\) is the random error associated to \(y_{ij}\). In this example, we will use the example data data_g from metan package.

The easiest way of obtaining the results of the model above is by using the function get_model_data(). Let’s do it.

  • Details of the analysis
  • Likelihood ratio test for genotype effect
  • Variance components and genetic parameters
  • Predicted means

In the above example, the experimental design was a complete randomized block. It is also possible to analyze an experiment conducted in an alpha-lattice design with the function gamem(). In this case, the following model is fitted:

\[ y_{ijk}= \mu + \alpha_i + \gamma_j + (\gamma \tau)_{jk} + \varepsilon_{ijk} \]

where \(y_{ijk}\) is the observed value of the ith genotype in the kth block of the jth replicate (i = 1, 2, … g; j = 1, 2, .., r; k = 1, 2, .., b); respectively; \(\alpha_i\) is the random effect of the ith genotype; \(\gamma_j\) is the fixed effect of the jth complete replicate; \((\gamma \tau)_{jk}\) is the random effect of the kth incomplete block nested within the j replicate; and \(\varepsilon_{ijk}\) is the random error associated to \(y_{ijk}\). In this example, we will use the example data data_alpha from metan package.

The BLUP model for MET trials

The simplest and well-known linear model with interaction effect used to analyze data from multi-environment trials is \[ {y_{ijk}} = {\rm{ }}\mu {\rm{ }} + \mathop \alpha \nolimits_i + \mathop \tau \nolimits_j + \mathop {(\alpha \tau )}\nolimits_{ij} + \mathop \gamma \nolimits_{jk} + {\rm{ }}\mathop \varepsilon \nolimits_{ijk} \]

where \({y_{ijk}}\) is the response variable (e.g., grain yield) observed in the kth block of the ith genotype in the jth environment (i = 1, 2, …, g; j = 1, 2, …, e; k = 1, 2, …, b); \(\mu\) is the grand mean; \(\mathop \alpha \nolimits_i\) is the effect of the ith genotype; \(\mathop \tau \nolimits_j\) is the effect of the jth environment; \(\mathop {(\alpha \tau )}\nolimits_{ij}\) is the interaction effect of the ith genotype with the jth environment; \(\mathop \gamma \nolimits_{jk}\) is the effect of the kth block within the jth environment; and \(\mathop \varepsilon \nolimits_{ijk}\) is the random error. In a mixed-effect model assuming \({\alpha _i}\) and \(\mathop {(\alpha \tau )}\nolimits_{ij}\) to be random effects, the above model can be rewritten as follows

\[ {\boldsymbol{y = X\beta + Zu + \varepsilon }} \]

where y is an \(n[ = \sum\nolimits_{j = 1}^e {(gb)]} \times 1\) vector of response variable \({\bf{y}} = {\rm{ }}{\left[ {{y_{111}},{\rm{ }}{y_{112}},{\rm{ }} \ldots ,{\rm{ }}{y_{geb}}} \right]^\prime }\); \({\bf{\beta }}\) is an \((eb) \times 1\) vector of unknown fixed effects \({\boldsymbol{\beta }} = [\mathop \gamma \nolimits_{11} ,\mathop \gamma \nolimits_{12} ,...,\mathop \gamma \nolimits_{eb} ]'\); u is an \(m[ = g + ge] \times 1\) vector of random effects \({\boldsymbol{u}} = {\rm{ }}{\left[ {{\alpha _1},{\alpha _2},...,{\alpha _g},\mathop {(\alpha \tau )}\nolimits_{11} ,\mathop {(\alpha \tau )}\nolimits_{12} ,...,\mathop {(\alpha \tau )}\nolimits_{ge} } \right]^\prime }\); X is an \(n \times (eb)\) design matrix relating y to \({\bf{\beta }}\); Z is an \(n \times m\) design matrix relating y to u ; \({\boldsymbol{\varepsilon }}\) is an \(n \times 1\) vector of random errors \({\boldsymbol{\varepsilon }} = {\rm{ }}{\left[ {{y_{111}},{\rm{ }}{y_{112}},{\rm{ }} \ldots ,{\rm{ }}{y_{geb}}} \right]^\prime }\);

The vectors \({\boldsymbol{\beta }}\) and u are estimated using the well-known mixed model equation (Henderson 1975). \[ \left[ {\begin{array}{*{20}{c}}{{\boldsymbol{\hat \beta }}}\\{{\bf{\hat u}}}\end{array}} \right]{\bf{ = }}{\left[ {\begin{array}{*{20}{c}}{{\bf{X'}}{{\bf{r }}^{ - {\bf{1}}}}{\bf{X}}}&{{\bf{X'}}{{\bf{r }}^{ - {\bf{1}}}}{\bf{Z}}}\\{{\bf{Z'}}{{\bf{r }}^{ - {\bf{1}}}}{\bf{X}}}&{{\bf{Z'}}{{\bf{r }}^{ - {\bf{1}}}}{\bf{Z + }}{{\bf{G}}^{ - {\bf{1}}}}}\end{array}} \right]^ - }\left[ {\begin{array}{*{20}{c}}{{\bf{X'}}{{\bf{r }}^{ - {\bf{1}}}}{\bf{y}}}\\{{\bf{Z'}}{{\bf{r }}^{ - {\bf{1}}}}{\bf{y}}}\end{array}} \right] \] where G and R are the variance-covariance matrices for random-effect vector u and residual vector \({\bf{\varepsilon }}\), respectively.

The function gamem_met() is used to fit the linear mixed-effect model. The first argument is the data, in our example data_ge. The arguments (env, gen, and rep) are the name of the columns that contains the levels for environments, genotypes, and replications, respectively.The argument (resp) is the response variable to be analyzed. The function allow a single variable (in this case GY) or a vector of response variables. Here, we will use everything() to analyse all numeric variables in the data. By default, genotype and genotype-vs-environment interaction are assumed to be random effects. Other effects may be considered using the random argument. The last argument (verbose) control if the code is run silently or not.

Diagnostic plot for residuals

The S3 generic function plot() is used to generate diagnostic plots of residuals of the model.

The normality of the random effects of genotype and interaction effects may be also obtained by using type = "re".

plot(mixed_mod, type = "re")

Printing the model outputs

Likelihood Ratio Tests

The output LRT contains the Likelihood Ratio Tests for genotype and genotype-vs-environment random effects. We can get these values with get_model_data()

Variance components and genetic parameters

In the output ESTIMATES, beyond the variance components for the declared random effects, some important parameters are also shown. Heribatility is the broad-sense heritability, \(\mathop h\nolimits_g^2\), estimated by \[ \mathop h\nolimits_g^2 = \frac{\mathop {\hat\sigma} \nolimits_g^2} {\mathop {\hat\sigma} \nolimits_g^2 + \mathop {\hat\sigma} \nolimits_i^2 + \mathop {\hat\sigma} \nolimits_e^2 } \]

where \(\mathop {\hat\sigma} \nolimits_g^2\) is the genotypic variance; \(\mathop {\hat\sigma} \nolimits_i^2\) is the genotype-by-environment interaction variance; and \(\mathop {\hat\sigma} \nolimits_e^2\) is the residual variance.

GEIr2 is the coefficient of determination of the interaction effects, \(\mathop r\nolimits_i^2\), estimated by

\[ \mathop r\nolimits_i^2 = \frac{\mathop {\hat\sigma} \nolimits_i^2} {\mathop {\hat\sigma} \nolimits_g^2 + \mathop {\hat\sigma} \nolimits_i^2 + \mathop {\hat\sigma} \nolimits_e^2 } \] Heribatility of means is the heribability on the mean basis, \(\mathop h\nolimits_{gm}^2\), estimated by

\[ \mathop h\nolimits_{gm}^2 = \frac{\mathop {\hat\sigma} \nolimits_g^2}{[\mathop {\hat\sigma} \nolimits_g^2 + \mathop {\hat\sigma} \nolimits_i^2 /e + \mathop {\hat\sigma} \nolimits_e^2 /\left( {eb} \right)]} \]

where e and b are the number of environments and blocks, respectively; Accuracy is the accuracy of selection, Ac, estimated by \[ Ac = \sqrt{\mathop h\nolimits_{gm}^2} \]

rge is the genotype-environment correlation, \(\mathop r\nolimits_{ge}\), estimated by

\[ \mathop r\nolimits_{ge} = \frac{\mathop {\hat\sigma} \nolimits_g^2}{\mathop {\hat\sigma} \nolimits_g^2 + \mathop {\hat\sigma} \nolimits_i^2} \]

CVg and CVr are the the genotypic coefficient of variation and the residual coefficient of variation estimated, respectively, by \[ CVg = \left( {\sqrt {\mathop {\hat \sigma }\nolimits_g^2 } /\mu } \right) \times 100 \] and \[ CVr = \left( {\sqrt {\mathop {\hat \sigma }\nolimits_e^2 } /\mu } \right) \times 100 \] where \(\mu\) is the grand mean.

CV ratio is the ratio between genotypic and residual coefficient of variation.

BLUP for genotypes

The function get_model_data() may be used to easily get the data from a model fitted with the function gamem_met(), especially when more than one variables are used. The following code return the predicted mean of each genotype for five variables of the data data_ge2.

Plotting the BLUP for genotypes

a <- plot_blup(mixed_mod)
b <- plot_blup(mixed_mod, 
               col.shape  =  c("gray20", "gray80"),
               plot_theme = theme_metan(grid = "y")) +
arrange_ggplot(a, b, labels = letters[1:2])

This output shows the predicted means for genotypes. BLUPg is the genotypic effect \((\hat{g}_{i})\), which considering balanced data and genotype as random effect is estimated by

\[ \hat{g}_{i} = h_g^2(\bar{y}_{i.}-\bar{y}_{..}) \]

where \(h_g^2\) is the shrinkage effect for genotype. Predicted is the predicted mean estimated by \[ \hat{g}_{i}+\mu \]

where \(\mu\) is the grand mean. LL and UL are the lower and upper limits, respectively, estimated by \[ (\hat{g}_{i}+\mu)\pm{CI} \] with \[ CI = t\times\sqrt{((1-Ac)\times{\mathop \sigma \nolimits_g^2)}} \]

where \(t\) is the Student’s t value for a two-tailed t test at a given probability error; \(Ac\) is the accuracy of selection and \(\mathop \sigma \nolimits_g^2\) is the genotypic variance.

BLUP for genotypes X environment combination

This output shows the predicted means for each genotype and environment combination. BLUPg is the genotypic effect described above. BLUPge is the genotypic effect of the ith genotype in the jth environment \((\hat{g}_{ij})\), which considering balanced data and genotype as random effect is estimated by \[\hat{g}_{ij} = h_g^2(\bar{y}_{i.}-\bar{y}_{..})+h_{ge}^2(y_{ij}-\bar{y}_{i.}-\bar{y}_{.j}+\bar{y}_{..})\] where \(h_{ge}^2\) is the shrinkage effect for the genotype-by-environment interaction; BLUPg+ge is \(BLUP_g+BLUP_{ge}\); Predicted is the predicted mean (\(\hat{y}_{ij}\)) estimated by \[ \hat{y}_{ij} = \bar{y}_{.j}+BLUP_{g+ge} \]

Some useful information

The following pieces of information are provided in Details output. Nenv, the number of environments in the analysis; Ngen the number of genotypes in the analysis; mresp The value attributed to the highest value of the response variable after rescaling it; wresp The weight of the response variable for estimating the WAASBY index. Mean the grand mean; SE the standard error of the mean; SD the standard deviation. CV the coefficient of variation of the phenotypic means, estimating WAASB, Min the minimum value observed (returning the genotype and environment), Max the maximum value observed (returning the genotype and environment); MinENV the environment with the lower mean, MaxENV the environment with the larger mean observed, MinGEN the genotype with the lower mean, MaxGEN the genotype with the larger.

The WAASB object

The function waasb() function computes the Weighted Average of the Absolute Scores considering all possible IPCA from the Singular Value Decomposition of the BLUPs for genotype-vs-environment interaction effects obtained by an Linear Mixed-effect Model (Olivoto et al. 2019), as follows:

\[ WAASB_i = \sum_{k = 1}^{p} |IPCA_{ik} \times EP_k|/ \sum_{k = 1}^{p}EP_k \]

where \(WAASB_i\) is the weighted average of absolute scores of the ith genotype; \(IPCA_{ik}\) is the scores of the ith genotype in the kth IPCA; and \(EP_k\) is the explained variance of the kth PCA for \(k = 1,2,..,p\), \(p = min(g-1; e-1)\).

The output generated by the waasb() function is very similar to those generated by the waas() function. The main difference here, is that the singular value decomposition is based on the BLUP for GEI effects matrix.

Eigenvalues of the BLUP_GEI matrix

plot_eigen(waasb_model, size.lab = 14, size.tex.lab = 14)

The above output shows the eigenvalues and the proportion of variance explained by each principal component axis of the BLUP interaction effects matrix.

Phenotypic means

In this output, Y is the phenotypic mean for each genotype and environment combination (\(y_{ij}\)), estimated by \(y_{ij} = \sum_k{y_{ij}}/B\) with \(k = 1,2,...B\).


Provided that an object of class waasb is available in the global environment, the graphics may be obtained using the function plot_scores(). To do that, we will revisit the previusly fitted model WAASB . Please, refer to ?plot_scores for more details. Four types of graphics can be generated: 1 = \(PC1 \times PC2\); 2 = \(GY \times PC1\); 3 = \(GY \times WAASB\); and 4 = a graphic with nominal yield as a function of the environment PCA1 scores.

biplot type 1: PC1 x PC2

biplot type 2: GY x PC1

biplot type 3: GY x WAASB

The quadrants proposed by Olivoto et al. (2019) in the following biplot represent four classifications regarding the joint interpretation of mean performance and stability. The genotypes or environments included in quadrant I can be considered unstable genotypes or environments with high discrimination ability, and with productivity below the grand mean. In quadrant II are included unstable genotypes, although with productivity above the grand mean. The environments included in this quadrant deserve special attention since, in addition to providing high magnitudes of the response variable, they present a good discrimination ability. Genotypes within quadrant III have low productivity, but can be considered stable due to the lower values of WAASB. The lower this value, the more stable the genotype can be considered. The environments included in this quadrant can be considered as poorly productive and with low discrimination ability. The genotypes within the quadrant IV are highly productive and broadly adapted due to the high magnitude of the response variable and high stability performance (lower values of WAASB).

g <- plot_scores(waasb_model, type = 3)
h <- plot_scores(waasb_model, type = 3,
                 x.lab = "My customized x label",
                 size.shape = 3,
        = 2,
                 x.lim = c(1.2, 4.7),
                 x.breaks = seq(1.5, 4.5, by = 0.5),
                 plot_theme = theme_metan(color.background = "white"))
arrange_ggplot(g, h, labels = letters[7:8])

To obtain the WAASB index for a set of variables, the function get_model_data() is used, as shown bellow.

biplot type 4 : nominal yield and environment IPCA1

Simultaneous selection for mean performance and stability

The waasby index is used for genotype ranking considering both the stability (waasb) and mean performance (y) based on the following model (Olivoto et al. 2019).

\[ waasby_i = \frac{{\left( {r {Y_i} \times {\theta _Y}} \right) + \left( {r {W_i} \times {\theta _W}} \right)}}{{{\theta _Y} + {\theta _W}}} \]

where \(waasby_i\) is the superiority index for the i-th genotype; \(rY_i\) and \(rW_i\) are the rescaled values (0-100) for the response variable (y) and the stability (WAAS or WAASB), respectively; \(\theta _Y\) and \(\theta_W\) are the weights for mean performance and stability, respectively.

This index was also already computed and stored into AMMI_model>GY>model. An intuitively plot may be obtained by running

i <- plot_waasby(waasb_model)
j <- plot_waasby(waasb_model, col.shape = c("gray20", "gray80"))
arrange_ggplot(i, j, labels = letters[9:10])

In the following example, we will apply the function wsmp() to the previously fitted model waasb_model aiming at planning different scenarios of waasby estimation by changing the weights assigned to the stability and the mean performance.vThe number of scenarios is defined by the arguments increment. By default, twenty-one different scenarios are computed. In this case, the the superiority index waasby is computed considering the following weights: stability (waasb or waas) = 100; mean performance = 0. In other words, only stability is considered for genotype ranking. In the next iteration, the weights becomes 95/5 (since increment = 5). In the third scenario, the weights become 90/10, and so on up to these weights become 0/100. In the last iteration, the genotype ranking for WAASY or WAASBY matches perfectly with the ranks of the response variable.

scenarios <- wsmp(waasb_model)

Printing the model outputs

In addition, the genotype ranking depending on the number of multiplicative terms used to estimate the WAAS index is also computed.

Plotting the heat map graphics

The first type of heatmap shows the genotype ranking depending on the number of principal component axes used for estimating the WAASB index. An euclidean distance-based dendrogram is used for grouping the genotypes based on their ranks. The second type of heatmap shows the genotype ranking depending on the WAASB/GY ratio. The ranks obtained with a ratio of 100/0 considers exclusively the stability for genotype ranking. On the other hand, a ratio of 0/100 considers exclusively the productivity for genotype ranking. Four clusters are estimated (1) unproductive and unstable genotypes; (2) productive, but unstable genotypes; (3) stable, but unproductive genotypes; and (4), productive and stable genotypes (Olivoto et al. 2019).

Ranks of genotypes depending on the number of PCA used to estimate the WAASB

plot(scenarios, type = 1)

Ranks of genotypes depending on the WAASB/GY ratio

plot(scenarios, type = 2)

Others BLUP-based stability indexes

Colombari Filho et al. (2013) have shown the use of three BLUP-based indexes for selecting genotypes with performance and stability. The first is the harmonic mean of genotypic values -or BLUPS- (HMGV) a stability index that considers the genotype with the highest harmonic mean across environments as the most stable, as follows:

\[ HMGV_i = \frac{1}{e}\sum\limits_{j = 1}^e {\frac{1}{{BLUP_{ij}}}} \]

The second is the relative performance of genotypic values (RPGV), an adaptability index estimated as follows:

\[ RPGV_i = \frac{1}{e}{\sum\limits_{j = 1}^e {BLUP_{ij}} /\mathop \mu \nolimits_j } \]

The third and last is the harmonic mean of relative performance of genotypic values (HMRPGV), a simultaneous selection index for stability, adaptability and mean performance, estimated as follows:

\[ HMRPGV_i = \frac{1}{e}\sum\limits_{j = 1}^e {\frac{1}{{BLUP_{ij}/{\mu _j}}}} \]

Res_ind <- 
data_ge %>%
waasb(ENV, GEN, REP, resp = GY, verbose = FALSE) %>% 


FAI-BLUP selection index

The FAI-BLUP is a multi-trait index based on factor analysis and ideotype-design recentely proposed by Rocha, Machado, and Carneiro (2018). It is based on factor analysis, when the factorial scores of each ideotype are designed according to the desirable and undesirable factors. Then, a spatial probability is estimated based on genotype-ideotype distance, enabling genotype ranking (Rocha, Machado, and Carneiro 2018).

data_ge2 %>%
  gamem_met(ENV, GEN, REP, c(KW, NKE, PH, EH)) %>%
  fai_blup(DI = c("max, max, max, min"),
           UI = c("min, min, min, max"),
           SI = 15) %>%
# ---------------------------------------------------------------------------
# P-values for Likelihood Ratio Test of the analyzed traits
# ---------------------------------------------------------------------------
#     model       KW     NKE       PH       EH
#  COMPLETE       NA      NA       NA       NA
#       GEN 6.21e-01 1.00000 9.39e-01 1.00e+00
#   GEN:ENV 4.92e-07 0.00101 1.09e-13 8.12e-12
# ---------------------------------------------------------------------------
# All variables with significant (p < 0.05) genotype-vs-environment interaction
# -----------------------------------------------------------------------------------
# Principal Component Analysis
# -----------------------------------------------------------------------------------
#     eigen.values cumulative.var
# PC1    3.1441417       78.60354
# PC2    0.6604119       95.11384
# PC3    0.1385777       98.57828
# PC4    0.0568688      100.00000
# -----------------------------------------------------------------------------------
# Factor Analysis
# -----------------------------------------------------------------------------------
#           FA1 comunalits
# KW  0.9474560  0.8976729
# NKE 0.7429933  0.5520391
# PH  0.9429971  0.8892436
# EH  0.8973216  0.8051860
# -----------------------------------------------------------------------------------
# Comunalit Mean: 0.7860354 
# Selection differential
# -----------------------------------------------------------------------------------
#     Factor         Xo         Xs           SD       SDperc
# KW       1 172.938867 175.182040 2.243173e+00 1.297090e+00
# NKE      1 511.643590 511.643590 2.819513e-07 5.510697e-08
# PH       1   2.484813   2.487051 2.238030e-03 9.006835e-02
# EH       1   1.343326   1.343326 3.234133e-10 2.407557e-08
# -----------------------------------------------------------------------------------
# Selected genotypes
# H13 H6
# -----------------------------------------------------------------------------------

  • IMPORTANT fai_blup() recognizes models fitted with both gamem_met() and waasb(). For balanced data (all genotypes in all environments) waasb() and gamem_met() will return the same model. In case of unbalanced trials, the function waasb() will return an error since a complete two-way table is required to the singular value decomposition procedure.

Rendering engine

This vignette was built with pkgdown. All tables were produced with the package DT using the following function.

library(DT) # Used to make the tables
# Function to make HTML tables
print_table <- function(table, rownames = FALSE, ...){
datatable(table, rownames = rownames, extensions = 'Buttons',
          options = list(scrollX = TRUE, dom = '<<t>Bp>', buttons = c('copy', 'excel', 'pdf', 'print')), ...) %>%
    formatSignif(columns = c(1:ncol(table)), digits = 3)}


Colombari Filho, J. M., M. D. V. Resende, O. P. Morais, A. P. Castro, É. P. Guimarães, J. A. Pereira, M. M. Utumi, and F. Breseghello. 2013. “Upland rice breeding in Brazil: a simultaneous genotypic evaluation of stability, adaptability and grain yield.” Euphytica 192 (1): 117–29.

Henderson, C. R. 1975. “Best Linear Unbiased Estimation and Prediction under a Selection Model.” Biometrics 31 (2): 423–47.

Olivoto, T., A. D. C Lúcio, J. A. G. Da silva, V. S. Marchioro, V. Q. de Souza, and E. Jost. 2019. “Mean performance and stability in multi-environment trials I: Combining features of AMMI and BLUP techniques.” Agronomy Journal 111 (6): 2949–60.

Rocha, João Romero do Amaral Santos de Car, Juarez Campolina Machado, and Pedro Crescêncio Souza Carneiro. 2018. “Multitrait index based on factor analysis and ideotype-design: proposal and application on elephant grass breeding for bioenergy.” GCB Bioenergy 10 (1): 52–60.