| Title: | Bayesian Estimation of the Additive Main Effects and Multiplicative Interaction Model |
|---|---|
| Description: | Bayesian estimation of the additive main effects and multiplicative interaction (AMMI) model of multi-environment trials by the Gibbs sampler of Crossa, Perez-Elizalde, Jarquin, Cotes, Viele, Liu and Cornelius (2011) <doi:10.2135/cropsci2010.06.0343>: posterior distributions of the overall mean, genotype and environment effects, singular values, genotype and environment scores (von Mises-Fisher conditionals on the constrained spheres) and error variance; several chains with burn-in and thinning; posterior summaries with highest posterior density intervals; the convergence diagnostics of Raftery-Lewis, Heidelberger-Welch and Gelman-Rubin; the AMMI biplot with highest posterior density regions for inference on genotypes and environments; least-squares AMMI; and a plain-language interpretation of every result, computed from its numbers. Beyond the article: unbalanced trials with missing plots and cells (data augmentation), environment-specific error variances, the Bayesian GGE (sites regression) model of Perez-Elizalde, Jarquin and Crossa (2012) <doi:10.1007/s13253-011-0063-9>, probabilities of superior performance and stability (Dias et al. 2022 <doi:10.1007/s00122-022-04041-y>), posterior ranks, Bayesian stability measures, predictions and the winner of every environment, model choice by DIC and WAIC with posterior predictive checks, draws for the 'posterior', 'bayesplot' and 'coda' packages, a compiled sampler, and a built-in 'shiny' application. Bayesian stability analysis: the Finlay-Wilkinson, Eberhart-Russell and Shukla models by Gibbs sampling, and the posterior distributions of classical stability indices (Wricke, Shukla, Lin-Binns, Annicchiarico, Eskridge's safety-first) and of AMMI-based indices (ASV, SIPC, EV, Za, WAAS, WAASY). Every result prints the references of its method. |
| Authors: | Muhammad Yaseen [aut, cre] (ORCID: <https://orcid.org/0000-0002-5923-1714>), Jose Crossa [aut, ctb], Sergio Perez-Elizalde [aut, ctb], Diego Jarquin [aut, ctb], Jose Miguel Cotes [aut, ctb], Kert Viele [aut, ctb], Genzhou Liu [aut, ctb], Paul L. Cornelius [aut, ctb], Julian Garcia Abadillo Velasco [aut, ctb] |
| Maintainer: | Muhammad Yaseen <[email protected]> |
| License: | GPL-2 |
| Version: | 1.0.0 |
| Built: | 2026-11-07 07:32:57 UTC |
| Source: | https://github.com/myaseen208/bayesammi |
bam_ammi_indices() computes the AMMI stability value and the other stability indices built from the
singular values and genotype scores of an AMMI or GGE fit on every posterior draw: ASV (Purchase et al. 2000),
SIPC (Sneller et al. 1997), EV (Zobel 1994), Za (Zali et al. 2012), WAAS and the mean-stability index WAASY
(Olivoto et al. 2019).
bam_ammi_indices(fit, higher_better = TRUE, .weight_y = 50)bam_ammi_indices(fit, higher_better = TRUE, .weight_y = 50)
fit |
a result of |
higher_better |
|
.weight_y |
weight |
With multiplicative terms, singular values , genotype scores
, coordinates and the share of term in the fitted interaction
, on every draw:
ASV, with the ratio of the posterior means of the singular values (as in
bam_stability(); a ratio of draws explodes when comes near zero);
needs .
SIPC.
EV.
Za.
WAAS (the weights sum to one).
WAASY, where
rescales the genotype means to 0-100 (100 for the best) and rescales WAAS
to 0-100 (100 for the most stable); larger is better.
All but WAASY are smaller for more stable genotypes. The shares are those of the
fitted terms; Zali et al. (2012) and Olivoto et al. (2019) use the shares of the significant terms in
the whole interaction, which differ by a constant factor for Za and not at all for WAAS.
An object of class c("bam_ammi_indices", "bam_result", "list") with indices and
means, as in bam_indices().
Methods: print(), plot(), bam_interpret(), bam_cite().
Muhammad Yaseen ([email protected])
Purchase, J. L., Hatting, H. and van Deventer, C. S. (2000). Genotype x environment interaction of winter wheat (Triticum aestivum L.) in South Africa: II. Stability analysis of yield performance. South African Journal of Plant and Soil, 17(3), 101–107.
Sneller, C. H., Kilgore-Norquest, L. and Dombek, D. (1997). Repeatability of yield stability statistics in soybean. Crop Science, 37(2), 383–390.
Zobel, R. W. (1994). Stress resistance and root systems. In Proceedings of the Workshop on Adaptation of Plants to Soil Stress, INTSORMIL Publication 94-2, 80–99. University of Nebraska-Lincoln.
Zali, H., Farshadfar, E., Sabaghpour, S. H. and Karimizadeh, R. (2012). Evaluation of genotype x environment interaction in chickpea using measures of stability from AMMI model. Annals of Biological Research, 3(7), 3126–3136.
Olivoto, T., Lucio, A. D. C., da Silva, J. A. G., Marchioro, V. S., de Souza, V. Q. and Jost, E. (2019). Mean performance and stability in multi-environment trials I: combining features of AMMI and BLUP techniques. Agronomy Journal, 111(6), 2949–2960. doi:10.2134/agronj2019.03.0220
Other stability:
bam_indices(),
bam_stab_priors(),
bayes_stability()
data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 600 , .k = 2 , .burnin = 100 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) ai <- bam_ammi_indices( fit = fit , higher_better = TRUE , .weight_y = 50 ) ai$means plot(x = ai)data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 600 , .k = 2 , .burnin = 100 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) ai <- bam_ammi_indices( fit = fit , higher_better = TRUE , .weight_y = 50 ) ai$means plot(x = ai)
bam_app() starts the application of bayesammi: load a trial (the example Maiz or a CSV
file with one row per plot), fit the Bayesian AMMI or GGE model, check convergence, draw the biplot with HPD
regions, and turn the posterior into decisions (which genotype wins where, probabilities of superior performance
and stability, ranks, Bayesian stability, predictions of missing cells), and compare models. Every page shows an
interpretation computed from the results (bam_interpret()), the output as R prints it, formatted
tables, plots and the R code that repeats the analysis, each with a Copy button.
bam_app(launch.browser = interactive(), ...) bam_app_object()bam_app(launch.browser = interactive(), ...) bam_app_object()
launch.browser |
passed to |
... |
further arguments to |
The application needs the suggested packages shiny, bslib and DT. Plots are sent to the browser as WebP images when magick is installed (smaller than PNG; PNG otherwise) and can be downloaded as PNG, PDF or WebP. Text is set in IBM Plex Sans and output in IBM Plex Mono when the browser can reach Google Fonts, in the system fonts otherwise.
bam_app() is called for its side effect and returns the value of shiny::runApp() when the
application is closed; bam_app_object() returns the application object (for shiny::runApp(),
shiny::testServer() or deployment on a server).
Muhammad Yaseen ([email protected])
if (interactive()) { bam_app( launch.browser = TRUE ) }if (interactive()) { bam_app( launch.browser = TRUE ) }
bam_cite() gives the references of the methods behind a result of the package, or the references of
every method in the package, as text or BibTeX. citation("bayesammi") cites the package and its main
methods.
bam_cite(x = NULL, style = c("text", "bibtex"))bam_cite(x = NULL, style = c("text", "bibtex"))
x |
a result of a function of the package, or |
style |
|
An object of class bibentry (printed in the chosen style).
Muhammad Yaseen ([email protected])
bam_cite( x = NULL , style = "text" ) data(Maiz) g <- ge_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep ) bam_cite( x = g , style = "bibtex" )bam_cite( x = NULL , style = "text" ) data(Maiz) g <- ge_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep ) bam_cite( x = g , style = "bibtex" )
bam_compare() compares fits of bayes_ammi() that differ in the number of multiplicative
terms, the model (AMMI or GGE), the error variances or the priors, by the deviance information criterion (DIC)
and the widely applicable information criterion (WAIC). Smaller values predict new data better.
bam_compare(...)bam_compare(...)
... |
fits of |
With over the observed plots,
(Spiegelhalter et al. 2002), the deviance evaluated at the posterior means of the cell means and variances; and
(Watanabe 2010; Gelman et al. 2014), accumulated over all draws during sampling. All fits must use the same data.
The standard error of a difference in WAIC comes from the plot-by-plot differences of the contributions
to WAIC: (Vehtari et al. 2017). Because the models are fitted to the same plots, it is smaller
than the standard error of either WAIC. A difference of less than about two of its standard errors does not
separate two models.
An object of class c("bam_compare", "bam_result", "list") with table
(data.table sorted by WAIC: model, terms, variances, DIC, pD,
WAIC, p_waic, se (standard error of WAIC), lambda_last_lower (lower HPD limit of the
last singular value), lambda_last_mean, dWAIC (difference from the best) and dWAIC_se (its
standard error)).
Methods: print(), plot(), bam_interpret().
Muhammad Yaseen ([email protected])
Spiegelhalter, D. J., Best, N. G., Carlin, B. P. and van der Linde, A. (2002). Bayesian measures of model complexity and fit. Journal of the Royal Statistical Society B, 64(4), 583–639. doi:10.1111/1467-9868.00353
Watanabe, S. (2010). Asymptotic equivalence of Bayes cross validation and widely applicable information criterion in singular learning theory. Journal of Machine Learning Research, 11, 3571–3594.
Gelman, A., Hwang, J. and Vehtari, A. (2014). Understanding predictive information criteria for Bayesian models. Statistics and Computing, 24(6), 997–1016. doi:10.1007/s11222-013-9416-2
Vehtari, A., Gelman, A. and Gabry, J. (2017). Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC. Statistics and Computing, 27(5), 1413–1432. doi:10.1007/s11222-016-9696-4
Other model choice:
bam_ppc()
data(Maiz) fits <- lapply( X = 1:2 , FUN = function(K) { bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 600 , .k = K , .burnin = 100 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) } ) bam_compare( AMMI1 = fits[[1]] , AMMI2 = fits[[2]] )data(Maiz) fits <- lapply( X = 1:2 , FUN = function(K) { bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 600 , .k = K , .burnin = 100 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) } ) bam_compare( AMMI1 = fits[[1]] , AMMI2 = fits[[2]] )
bam_indices() computes five classical stability and superiority indices on every posterior draw of the cell
means of a fit, so that each index has a posterior mean, an HPD interval and, for every genotype, a probability of
being the best. The indices are those of Wricke (1962), Shukla (1972), Lin and Binns (1988), Annicchiarico (1992)
and Eskridge (1990).
bam_indices(fit, higher_better = TRUE, .prob = 0.25, .alpha = 0.05)bam_indices(fit, higher_better = TRUE, .prob = 0.25, .alpha = 0.05)
fit |
a result of |
higher_better |
|
.prob |
error probability |
.alpha |
probability |
With the cell mean of genotype in environment (one posterior draw),
, and
the genotype, environment and overall means, and the interaction
:
wrickeecovalence ; smaller is more stable.
shuklastability variance ;
smaller is more stable.
lin_binnssuperiority , the best cell mean of environment ; smaller is better.
annicchiaricoreliability with ; larger is better
(with higher_better = FALSE: , smaller better).
safety_firstEskridge's index with the variance across environments,
; larger is better (with
higher_better = FALSE: , smaller better).
bayes_stability() gives the model-based versions of the regression and Shukla models.
Because the indices are computed from the posterior of the cell means, they measure the stability of the expected performance, free of the plot error; the HPD intervals show how well the trial determines them.
An object of class c("bam_indices", "bam_result", "list") with
indicesdata.table in long form: index, Gen, mean, lower,
upper (HPD interval), prob_best (posterior probability that the genotype is the best on this
index) and rank_mean (expected rank, 1 = best).
meansdata.table: one row per genotype with the posterior means of the indices and the mean
of their expected ranks (rank_overall), sorted by it.
Methods: print(), plot(), bam_interpret(), bam_cite().
Muhammad Yaseen ([email protected])
Wricke, G. (1962). Uber eine Methode zur Erfassung der okologischen Streubreite in Feldversuchen. Zeitschrift fur Pflanzenzuchtung, 47, 92–96.
Shukla, G. K. (1972). Some statistical aspects of partitioning genotype-environmental components of variability. Heredity, 29(2), 237–245. doi:10.1038/hdy.1972.87
Lin, C. S. and Binns, M. R. (1988). A superiority measure of cultivar performance for cultivar x location data. Canadian Journal of Plant Science, 68(1), 193–198. doi:10.4141/cjps88-018
Annicchiarico, P. (1992). Cultivar adaptation and recommendation from alfalfa trials in Northern Italy. Journal of Genetics and Breeding, 46, 269–278.
Eskridge, K. M. (1990). Selection of stable cultivars using a safety-first rule. Crop Science, 30, 369–374.
bam_ammi_indices, bayes_stability, bam_superiority
Other stability:
bam_ammi_indices(),
bam_stab_priors(),
bayes_stability()
data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 600 , .k = 2 , .burnin = 100 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) ind <- bam_indices( fit = fit , higher_better = TRUE , .prob = 0.25 , .alpha = 0.05 ) ind$means plot(x = ind)data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 600 , .k = 2 , .burnin = 100 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) ind <- bam_indices( fit = fit , higher_better = TRUE , .prob = 0.25 , .alpha = 0.05 ) ind$means plot(x = ind)
bam_interpret() turns a result of bayes_ammi(), biplots() or
ge_ammi() into a plain-language interpretation: whether the chains have converged, which genotypes
and environments differ from the average (main effects whose HPD interval excludes zero), how strong the bilinear
terms are, which genotypes and environments interact significantly and in which direction, which are stable, and
what to check before acting on the results. Every statement is computed from the numbers of the result.
bam_interpret(x, higher_better = TRUE, top = 5L, ...) ## S3 method for class 'bam_interpretation' print(x, ...) ## S3 method for class 'bam_interpretation' format(x, style = c("text", "markdown"), width = getOption("width", 80L), ...)bam_interpret(x, higher_better = TRUE, top = 5L, ...) ## S3 method for class 'bam_interpretation' print(x, ...) ## S3 method for class 'bam_interpretation' format(x, style = c("text", "markdown"), width = getOption("width", 80L), ...)
x |
a result of |
higher_better |
|
top |
number of genotypes or environments named in lists (default 5). |
... |
unused. |
style |
|
width |
line width of the text (default |
The rules:
convergence: potential scale reduction factor below 1.1 (two or more chains), effective sample size of at least 400, Raftery-Lewis dependence factor below 5 and the Heidelberger-Welch tests passed (Crossa et al. 2011);
main effects: a genotype or environment differs from the average when the HPD interval of its effect excludes zero;
bilinear terms: a term whose HPD interval of reaches down to near zero (lower
limit below a tenth of the posterior mean) is weakly supported;
interaction: a genotype (environment) interacts significantly on the first term when the HPD interval of its first score excludes zero; genotypes and environments with significant scores of the same sign interact positively (the genotype does better there than its main effect predicts), of opposite sign negatively;
stability (biplots()): a genotype is stable when its HPD region contains the origin.
An object of class "bam_interpretation": a list with analysis, title,
headline, findings, recommendations and cautions (sentences), facts (the
numbers and lists behind the sentences), guide (how the method is read) and sources (the full
references of the method; bam_cite() gives them as BibTeX). print() shows the text;
format(x, style = "markdown") returns it as Markdown.
Muhammad Yaseen ([email protected])
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. Crop Science, 51(4), 1458–1469. doi:10.2135/cropsci2010.06.0343
data(Maiz) fm1 <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 500 , .k = 2 , .burnin = 100 , .thin = 1 , .chains = 2 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = c("AMMI", "GGE") , .het = FALSE , .waic = TRUE ) txt <- bam_interpret( x = fm1 , higher_better = TRUE , top = 5 ) txt cat(format(x = txt, style = "markdown"))data(Maiz) fm1 <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 500 , .k = 2 , .burnin = 100 , .thin = 1 , .chains = 2 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = c("AMMI", "GGE") , .het = FALSE , .waic = TRUE ) txt <- bam_interpret( x = fm1 , higher_better = TRUE , top = 5 ) txt cat(format(x = txt, style = "markdown"))
The symbols used in the help pages and vignettes of bayesammi, with their meaning and the argument or result
component that holds them. The notation follows one rule throughout: scalars are upper-case letters in normal
face (, ), indices lower-case italic (), vectors lower-case bold
(, ) and matrices upper-case bold (,
).
bam_notation(format = c("table", "path", "tex"))bam_notation(format = c("table", "path", "tex"))
format |
|
See format.
Muhammad Yaseen ([email protected])
Other bayesammi utilities:
bam_reference(),
bam_save(),
bam_theme()
bam_notation( format = c("table", "path", "tex")[1] )bam_notation( format = c("table", "path", "tex")[1] )
bam_ppc() compares statistics of the observed trial with their distribution in trials replicated from the
posterior predictive distribution (Gelman et al. 1996). A posterior predictive p-value near 0 or 1 shows a feature
of the data that the model does not reproduce, for instance unequal error variances or a missing interaction term.
bam_ppc(fit, .draws = 1000L, .seed = NULL)bam_ppc(fit, .draws = 1000L, .seed = NULL)
fit |
a result of |
.draws |
number of posterior draws used (default 1000). |
.seed |
seed for the replicated trials (the random number state of the session is restored). |
For a subset of .draws posterior draws, a trial with the observed
plots is simulated from , and for each statistic
. The
statistics: variance of the cell means, largest and smallest cell mean, variance of the genotype means, first
singular value of the interaction effects of the cell means, pooled within-cell variance, and the ratio of the
largest to the smallest within-environment variance.
An object of class c("bam_ppc", "bam_result", "list") with checks (data.table:
statistic, observed, mean_rep, p_value) and replicated (data.table of
the replicated statistics).
Methods: print(), plot(), bam_interpret().
Muhammad Yaseen ([email protected])
Gelman, A., Meng, X.-L. and Stern, H. (1996). Posterior predictive assessment of model fitness via realized discrepancies. Statistica Sinica, 6(4), 733–807.
Other model choice:
bam_compare()
data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 600 , .k = 2 , .burnin = 100 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) pc <- bam_ppc( fit = fit , .draws = 300 , .seed = 1 ) pc$checks plot(x = pc)data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 600 , .k = 2 , .burnin = 100 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) pc <- bam_ppc( fit = fit , .draws = 300 , .seed = 1 ) pc$checks plot(x = pc)
bam_predict() gives the posterior distribution of the expected response of every genotype in every
environment, including the cells that were not observed, and of the genotype means over the environments.
bam_predict(fit, .level = NULL)bam_predict(fit, .level = NULL)
fit |
a result of |
.level |
probability of the HPD intervals (default: that of the fit). |
For draw ,
(without in the GGE model); the genotype mean over the environments is . A missing cell is predicted from the main effects and from
the interaction pattern its genotype and environment show in the other cells; the data augmentation of
bayes_ammi() has already propagated its uncertainty into all parameters.
An object of class c("bam_predict", "bam_result", "list"):
cellsdata.table: Gen, Env, n (plots observed), observed
(their mean, NA when missing), mean, sd, lower, upper.
genotypesdata.table: posterior mean, sd and HPD interval of every genotype mean.
Methods: print(), plot() (which = c("cells", "genotypes")), bam_interpret().
Muhammad Yaseen ([email protected])
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. Crop Science, 51(4), 1458–1469. doi:10.2135/cropsci2010.06.0343
Other decisions:
bam_ranks(),
bam_stability(),
bam_superiority(),
bam_winners()
data(Maiz) d <- Maiz[!(Maiz$entry == 8 & Maiz$site == 8), ] fit <- bayes_ammi( .data = d , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 1000 , .k = 2 , .burnin = 200 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) pr <- bam_predict( fit = fit , .level = 0.95 ) pr$cells[n == 0]data(Maiz) d <- Maiz[!(Maiz$entry == 8 & Maiz$site == 8), ] fit <- bayes_ammi( .data = d , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 1000 , .k = 2 , .burnin = 200 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) pr <- bam_predict( fit = fit , .level = 0.95 ) pr$cells[n == 0]
bam_priors() sets the hyperparameters of the prior distributions of bayes_ammi(). The
defaults are the vague but proper priors of Crossa et al. (2011): normal priors with mean zero and variance
for the overall mean, the main effects and the singular values, and a scaled inverse
chi-square prior with one degree of freedom for the error variance.
bam_priors( mu_mean = 0, mu_var = 1e+08, tau_mean = 0, tau_var = 1e+08, delta_mean = 0, delta_var = 1e+08, lambda_mean = 0, lambda_var = 1e+08, nu = 1, s2 = NULL ) ## S3 method for class 'bam_priors' print(x, ...)bam_priors( mu_mean = 0, mu_var = 1e+08, tau_mean = 0, tau_var = 1e+08, delta_mean = 0, delta_var = 1e+08, lambda_mean = 0, lambda_var = 1e+08, nu = 1, s2 = NULL ) ## S3 method for class 'bam_priors' print(x, ...)
mu_mean, mu_var
|
prior mean and variance of the overall mean |
tau_mean, tau_var
|
prior mean (a scalar or a vector of length |
delta_mean, delta_var
|
prior mean (scalar or length |
lambda_mean, lambda_var
|
prior mean and variance of the singular values |
nu, s2
|
degrees of freedom |
x |
a |
... |
unused. |
With genotypes, environments and bilinear terms,
each main effect restricted to sum zero,
and spherical uniform priors for the singular vectors on the subspaces orthogonal to and to
the other vectors. = NULL (default) takes the residual mean square of the
least-squares AMMI fit, so that the prior is equally vague whatever the unit of the trait; with it carries the information of a single observation. Crossa et al. (2011) report ;
their published posterior of is reproduced with the vague default (see the vignette on
validation).
A list of class "bam_priors" with these elements.
Muhammad Yaseen ([email protected])
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. Crop Science, 51(4), 1458–1469. doi:10.2135/cropsci2010.06.0343
Hobert, J. P. and Casella, G. (1996). The effect of improper priors on Gibbs sampling in hierarchical linear mixed models. Journal of the American Statistical Association, 91(436), 1461–1473.
bam_priors( mu_mean = 0 , mu_var = 1e8 , tau_mean = 0 , tau_var = 1e8 , delta_mean = 0 , delta_var = 1e8 , lambda_mean = 0 , lambda_var = 1e8 , nu = 1 , s2 = NULL )bam_priors( mu_mean = 0 , mu_var = 1e8 , tau_mean = 0 , tau_var = 1e8 , delta_mean = 0 , delta_var = 1e8 , lambda_mean = 0 , lambda_var = 1e8 , nu = 1 , s2 = NULL )
bam_ranks() gives the posterior probability that each genotype takes each rank, by its mean over the
environments (the marginal value) or within one environment, with the expected rank and its HPD interval.
bam_ranks(fit, higher_better = TRUE, .env = NULL)bam_ranks(fit, higher_better = TRUE, .env = NULL)
fit |
a result of |
higher_better |
|
.env |
|
In draw the genotypes are ranked by (1 = best); the
probability of rank is the share of draws in which genotype takes it. Ranks summarise the
uncertainty of a selection decision better than intervals of the means, since they account for all the
genotypes jointly.
An object of class c("bam_ranks", "bam_result", "list"): probabilities (matrix genotypes x
ranks) and summary (data.table: Gen, mean_rank, median_rank, lower,
upper of the HPD interval of the rank, prob_first).
Methods: print(), plot(), bam_interpret().
Muhammad Yaseen ([email protected])
Dias, K. O. G., dos Santos, J. P. R., Krause, M. D., Piepho, H.-P., Guimaraes, L. J. M., Pastina, M. M. and Garcia, A. A. F. (2022). Leveraging probability concepts for cultivar recommendation in multi-environment trials. Theoretical and Applied Genetics. doi:10.1007/s00122-022-04041-y
Other decisions:
bam_predict(),
bam_stability(),
bam_superiority(),
bam_winners()
data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 1000 , .k = 2 , .burnin = 200 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) rk <- bam_ranks( fit = fit , higher_better = TRUE , .env = NULL ) rk$summary plot(x = rk)data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 1000 , .k = 2 , .burnin = 200 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) rk <- bam_ranks( fit = fit , higher_better = TRUE , .env = NULL ) rk$summary plot(x = rk)
Reads inst/extdata/reference.csv: one row per published number, with its source, the R call
that recomputes it with this package (call), the expression that extracts the number from the result
(extract, in terms of x), the printed value and the digits to compare. The same file drives the test
of published values and the vignette that reproduces the published examples. Each distinct call is evaluated once.
bam_reference(source = NULL, evaluate = FALSE, level = 1)bam_reference(source = NULL, evaluate = FALSE, level = 1)
source |
optional regular expression; keep rows whose |
evaluate |
logical; evaluate the rows and add columns |
level |
largest |
A data.table with columns id, source, quantity, call, extract,
value, digits, level, note (and computed, agrees).
Muhammad Yaseen ([email protected])
Other bayesammi utilities:
bam_notation(),
bam_save(),
bam_theme()
ref <- bam_reference( source = NULL , evaluate = FALSE , level = 1 ) ref bam_reference( source = "." , evaluate = TRUE , level = 1 )ref <- bam_reference( source = NULL , evaluate = FALSE , level = 1 ) ref bam_reference( source = "." , evaluate = TRUE , level = 1 )
A wrapper of ggsave with the defaults of the package: a vector PDF through
cairo_pdf (embedded fonts, correct glyphs), A4 landscape (11.69 x 8.27 inches) and 600
dpi for raster formats. The device follows the file extension for other formats (.png, .svg,
.tiff, ...).
bam_save( plot = ggplot2::last_plot(), filename, path = NULL, width = 11.69, height = 8.27, units = c("in", "cm", "mm"), dpi = 600, scale = 1, device = NULL, limitsize = TRUE, ... )bam_save( plot = ggplot2::last_plot(), filename, path = NULL, width = 11.69, height = 8.27, units = c("in", "cm", "mm"), dpi = 600, scale = 1, device = NULL, limitsize = TRUE, ... )
plot |
a |
filename |
file name; its extension chooses the format. |
path |
directory to save in (default |
width, height
|
size (default 11.69 x 8.27, A4 landscape, in |
units |
|
dpi |
resolution for raster formats (default 600). |
scale |
multiplicative scaling factor (default 1). |
device |
|
limitsize |
logical; refuse images larger than 50 x 50 inches (default |
... |
passed to |
The file name, invisibly.
Muhammad Yaseen ([email protected])
Other bayesammi utilities:
bam_notation(),
bam_reference(),
bam_theme()
library(ggplot2) p <- ggplot(data = data.frame(x = 1:10, y = (1:10)^2), mapping = aes(x = x, y = y)) + geom_line() + bam_theme( base_size = 11 , base_family = "serif" , ticks_inward = TRUE , legend_position = "bottom" ) f <- tempfile(fileext = ".pdf") bam_save( plot = p , filename = f , path = NULL , width = 11.69 , height = 8.27 , units = c("in", "cm", "mm")[1] , dpi = 600 , scale = 1 , device = NULL , limitsize = TRUE ) bam_save( plot = p , filename = basename(f) , path = tempdir() , width = 11.69 , height = 8.27 , units = c("in", "cm", "mm")[1] , dpi = 600 , scale = 1 , device = grDevices::cairo_pdf , limitsize = TRUE ) bam_save( plot = p , filename = tempfile(fileext = ".png") , path = NULL , width = 6 , height = 4 , units = c("in", "cm", "mm")[1] , dpi = 300 , scale = 1 , device = NULL , limitsize = TRUE )library(ggplot2) p <- ggplot(data = data.frame(x = 1:10, y = (1:10)^2), mapping = aes(x = x, y = y)) + geom_line() + bam_theme( base_size = 11 , base_family = "serif" , ticks_inward = TRUE , legend_position = "bottom" ) f <- tempfile(fileext = ".pdf") bam_save( plot = p , filename = f , path = NULL , width = 11.69 , height = 8.27 , units = c("in", "cm", "mm")[1] , dpi = 600 , scale = 1 , device = NULL , limitsize = TRUE ) bam_save( plot = p , filename = basename(f) , path = tempdir() , width = 11.69 , height = 8.27 , units = c("in", "cm", "mm")[1] , dpi = 600 , scale = 1 , device = grDevices::cairo_pdf , limitsize = TRUE ) bam_save( plot = p , filename = tempfile(fileext = ".png") , path = NULL , width = 6 , height = 4 , units = c("in", "cm", "mm")[1] , dpi = 300 , scale = 1 , device = NULL , limitsize = TRUE )
bam_stab_priors() sets the prior distributions of bayes_stability(): normal priors for the
overall mean and the contrasts of the genotype effects, environment effects (the environmental index) and slope
deviations, and scaled inverse chi-squared priors for the error variance and the deviation variances.
bam_stab_priors( mu_var = NULL, g_var = NULL, h_var = NULL, b_var = 100, nu = 1, s2 = NULL, nu_d = 1, s2_d = NULL )bam_stab_priors( mu_var = NULL, g_var = NULL, h_var = NULL, b_var = 100, nu = 1, s2 = NULL, nu_d = 1, s2_d = NULL )
mu_var, g_var, h_var
|
prior variances of the overall mean and of the contrasts of the genotype and environment
effects ( |
b_var |
prior variance of the contrasts of the slope deviations |
nu, s2
|
degrees of freedom and scale of the prior of the error variance ( |
nu_d, s2_d
|
degrees of freedom and scale of the prior of the deviation variances ( |
where are the orthonormal contrasts of matrix_k(), so that the effects and
the slope deviations sum to zero. Variances left NULL are set from the data: times the
variance of the response for the effects, and the least-squares estimates for and
, so that the priors carry the information of and
observations whatever the unit of the trait.
An object of class c("bam_stab_priors", "list").
Muhammad Yaseen ([email protected])
Lian, L. and de los Campos, G. (2016). FW: an R package for Finlay-Wilkinson regression that incorporates genomic/pedigree information and covariance structures between environments. G3: Genes, Genomes, Genetics, 6(3), 589–597. doi:10.1534/g3.115.026328
Other stability:
bam_ammi_indices(),
bam_indices(),
bayes_stability()
bam_stab_priors( mu_var = NULL , g_var = NULL , h_var = NULL , b_var = 100 , nu = 1 , s2 = NULL , nu_d = 1 , s2_d = NULL )bam_stab_priors( mu_var = NULL , g_var = NULL , h_var = NULL , b_var = 100 , nu = 1 , s2 = NULL , nu_d = 1 , s2_d = NULL )
bam_stability() gives the posterior distributions of two stability measures of every genotype: the AMMI
stability value (ASV) of Purchase et al. (2000) computed draw by draw, and the variance of the interaction effects
over the environments (Shukla's stability variance of the model), with posterior means, HPD intervals, the
probability of being the most stable genotype and the posterior expected ranks, combined with the mean into a
Bayesian yield stability index.
bam_stability(fit, higher_better = TRUE)bam_stability(fit, higher_better = TRUE)
fit |
a result of |
higher_better |
|
With the biplot scores and the sums of
squares of the terms proportional to ,
( with one term), evaluated in every draw. The weight of the first
axis uses the posterior means of the singular values: the ratio of the draws
themselves has no finite mean when the posterior of reaches zero. The Bayesian yield
stability index is the sum of the posterior expected ranks of the mean and of the ASV.
An object of class c("bam_stability", "bam_result", "list") with stability
(data.table sorted by the index: Gen, mean, ASV, ASV_lower,
ASV_upper, variance, prob_most_stable (smallest ASV), rank_mean, rank_ASV,
YSI).
Methods: print(), plot(), bam_interpret().
Muhammad Yaseen ([email protected])
Purchase, J. L., Hatting, H. and van Deventer, C. S. (2000). Genotype x environment interaction of winter wheat in South Africa: II. Stability analysis of yield performance. South African Journal of Plant and Soil, 17(3), 101–107.
Shukla, G. K. (1972). Some statistical aspects of partitioning genotype-environmental components of variability. Heredity, 29(2), 237–245. doi:10.1038/hdy.1972.87
Other decisions:
bam_predict(),
bam_ranks(),
bam_superiority(),
bam_winners()
data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 1000 , .k = 2 , .burnin = 200 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) st <- bam_stability( fit = fit , higher_better = TRUE ) st$stabilitydata(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 1000 , .k = 2 , .burnin = 200 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) st <- bam_stability( fit = fit , higher_better = TRUE ) st$stability
bam_superiority() computes the probabilities of Dias et al. (2022) for recommending cultivars: the
probability that a genotype is among the best selected fraction across environments and within each environment,
the probability that it is among the most stable, their joint probability, and pairwise probabilities that one
genotype outperforms or is more stable than another.
bam_superiority(fit, .s = 0.2, higher_better = TRUE)bam_superiority(fit, .s = 0.2, higher_better = TRUE)
fit |
a result of |
.s |
selection intensity: the proportion of genotypes selected (default 0.2). |
higher_better |
|
With the genotypes with the best marginal values
in draw (selection intensity = .s),
where selects on within environment . Stability is the
variance over environments of the interaction effects (Shukla 1972):
is the probability that genotype is among the
genotypes with the smallest variance, and the joint probability is
, as in Dias et al. (2022). Pairwise,
and
.
An object of class c("bam_superiority", "bam_result", "list"):
marginaldata.table sorted by the joint probability: Gen, mean (posterior
mean of the marginal value), prob_performance, prob_stability, prob_joint.
conditionalmatrix : probability of superior performance in every
environment.
pairwise_performance, pairwise_stability
matrices : entry
is the probability that row genotype is better (more stable) than
.
Methods: print(), plot() (which = c("marginal", "conditional", "pairwise")),
bam_interpret().
Muhammad Yaseen ([email protected])
Dias, K. O. G., dos Santos, J. P. R., Krause, M. D., Piepho, H.-P., Guimaraes, L. J. M., Pastina, M. M. and Garcia, A. A. F. (2022). Leveraging probability concepts for cultivar recommendation in multi-environment trials. Theoretical and Applied Genetics. doi:10.1007/s00122-022-04041-y
Shukla, G. K. (1972). Some statistical aspects of partitioning genotype-environmental components of variability. Heredity, 29(2), 237–245. doi:10.1038/hdy.1972.87
bam_winners, bam_ranks, bam_stability
Other decisions:
bam_predict(),
bam_ranks(),
bam_stability(),
bam_winners()
data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 1000 , .k = 2 , .burnin = 200 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) sp <- bam_superiority( fit = fit , .s = 0.2 , higher_better = TRUE ) sp$marginal plot(x = sp, which = "marginal")data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 1000 , .k = 2 , .burnin = 200 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) sp <- bam_superiority( fit = fit , .s = 0.2 , higher_better = TRUE ) sp$marginal plot(x = sp, which = "marginal")
The theme used by every plot() method of bayesammi (identical in all packages of the
author): theme_classic with a serif font, black axis lines, ticks pointing inwards and no
grid, close to the look of TikZ/pgfplots figures in LaTeX documents. The plot() methods also use
scales::pretty_breaks(n = 10) on every continuous axis. Save figures with bam_save.
bam_theme( base_size = 11, base_family = "serif", ticks_inward = TRUE, legend_position = "bottom" )bam_theme( base_size = 11, base_family = "serif", ticks_inward = TRUE, legend_position = "bottom" )
base_size |
base font size in points (default 11). |
base_family |
font family (default |
ticks_inward |
logical; ticks point into the panel, as in pgfplots (default |
legend_position |
position of the legend (default |
A ggplot2 theme.
Muhammad Yaseen ([email protected])
Other bayesammi utilities:
bam_notation(),
bam_reference(),
bam_save()
library(ggplot2) p <- ggplot(data = data.frame(x = 1:20, y = cumsum(sin(1:20))), mapping = aes(x = x, y = y)) + geom_line() p + bam_theme( base_size = 11 , base_family = "serif" , ticks_inward = TRUE , legend_position = "bottom" ) p + bam_theme( base_size = 12 , base_family = "serif" , ticks_inward = FALSE , legend_position = "right" ) + scale_x_continuous(breaks = scales::pretty_breaks(n = 10))library(ggplot2) p <- ggplot(data = data.frame(x = 1:20, y = cumsum(sin(1:20))), mapping = aes(x = x, y = y)) + geom_line() p + bam_theme( base_size = 11 , base_family = "serif" , ticks_inward = TRUE , legend_position = "bottom" ) p + bam_theme( base_size = 12 , base_family = "serif" , ticks_inward = FALSE , legend_position = "right" ) + scale_x_continuous(breaks = scales::pretty_breaks(n = 10))
bam_winners() gives, for every environment, the posterior probability that each genotype has the best
expected response, the most probable winner, and the groups of environments with the same most probable winner
(candidate mega-environments). This is the Bayesian counterpart of the which-won-where view of the GGE biplot,
with a probability attached to every statement.
bam_winners(fit, higher_better = TRUE)bam_winners(fit, higher_better = TRUE)
fit |
a result of |
higher_better |
|
with the minimum instead of the maximum when higher_better = FALSE.
An object of class c("bam_winners", "bam_result", "list"):
probabilitiesmatrix of the probabilities .
winnersdata.table: Env, Winner (most probable), Probability,
Second and Probability2 (the runner-up).
megadata.table: groups of environments with the same most probable winner.
Methods: print(), plot(), bam_interpret().
Muhammad Yaseen ([email protected])
Yan, W., Hunt, L. A., Sheng, Q. and Szlavnics, Z. (2000). Cultivar evaluation and mega-environment investigation based on the GGE biplot. Crop Science, 40(3), 597–605. doi:10.2135/cropsci2000.403597x
Perez-Elizalde, S., Jarquin, D. and Crossa, J. (2012). A general Bayesian estimation method of linear-bilinear models applied to plant breeding trials with genotype x environment interaction. Journal of Agricultural, Biological, and Environmental Statistics, 17, 15–37. doi:10.1007/s13253-011-0063-9
Other decisions:
bam_predict(),
bam_ranks(),
bam_stability(),
bam_superiority()
data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 1000 , .k = 2 , .burnin = 200 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "GGE" , .het = FALSE , .waic = TRUE ) w <- bam_winners( fit = fit , higher_better = TRUE ) w$winners plot(x = w)data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 1000 , .k = 2 , .burnin = 200 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "GGE" , .het = FALSE , .waic = TRUE ) w <- bam_winners( fit = fit , higher_better = TRUE ) w$winners plot(x = w)
The draws of bayes_ammi() are a coda::mcmc.list (component draws). These methods hand
them to the packages posterior and coda; every plot of bayesplot (mcmc_trace(),
mcmc_areas(), mcmc_rank_overlay(), ...) then works on them, as does posterior::summarise_draws()
(rank-normalised , bulk and tail effective sample sizes).
## S3 method for class 'bam_bayes_ammi' as_draws_df(x, ...) ## S3 method for class 'bam_bayes_ammi' as_draws(x, ...) ## S3 method for class 'bam_bayes_ammi' as.mcmc.list(x, ...)## S3 method for class 'bam_bayes_ammi' as_draws_df(x, ...) ## S3 method for class 'bam_bayes_ammi' as_draws(x, ...) ## S3 method for class 'bam_bayes_ammi' as.mcmc.list(x, ...)
x |
a result of |
... |
unused. |
as_draws_df(): a posterior::draws_df; as_draws(): a posterior::draws_list;
as.mcmc.list(): the coda::mcmc.list.
Muhammad Yaseen ([email protected])
Gabry, J., Simpson, D., Vehtari, A., Betancourt, M. and Gelman, A. (2019). Visualization in Bayesian workflow. Journal of the Royal Statistical Society A, 182(2), 389–402. doi:10.1111/rssa.12378
Vehtari, A., Gelman, A., Simpson, D., Carpenter, B. and Burkner, P.-C. (2021). Rank-normalization, folding, and localization: an improved R-hat for assessing convergence of MCMC. Bayesian Analysis, 16(2), 667–718. doi:10.1214/20-BA1221
data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 500 , .k = 2 , .burnin = 100 , .thin = 1 , .chains = 2 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) if (requireNamespace("posterior", quietly = TRUE)) { dr <- posterior::as_draws_df(x = fit) posterior::summarise_draws( .x = posterior::subset_draws( x = dr , variable = c("mu", "lambda[1]", "lambda[2]") ) ) } if (requireNamespace("bayesplot", quietly = TRUE)) { bayesplot::mcmc_trace(x = fit$draws, pars = c("lambda[1]", "lambda[2]")) }data(Maiz) fit <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 500 , .k = 2 , .burnin = 100 , .thin = 1 , .chains = 2 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) if (requireNamespace("posterior", quietly = TRUE)) { dr <- posterior::as_draws_df(x = fit) posterior::summarise_draws( .x = posterior::subset_draws( x = dr , variable = c("mu", "lambda[1]", "lambda[2]") ) ) } if (requireNamespace("bayesplot", quietly = TRUE)) { bayesplot::mcmc_trace(x = fit$draws, pars = c("lambda[1]", "lambda[2]")) }
The analysis functions of bayesammi return the named list they have always returned, now with the class
c("bam_<analysis>", "bam_result", "list"). Components are read as before (x$ANOVA,
x[["Means"]]); the methods below print, summarise and plot the result and turn any component into a
data.table.
## S3 method for class 'bam_result' print(x, digits = 4L, ...) ## S3 method for class 'bam_result' summary(object, ...) ## S3 method for class 'summary.bam_result' print(x, ...) ## S3 method for class 'bam_result' format(x, ...) ## S3 method for class 'bam_result' as.data.table(x, keep.rownames = FALSE, ..., component = 1L) ## S3 method for class 'bam_result' as.data.frame(x, row.names = NULL, optional = FALSE, ..., component = 1L) ## S3 method for class 'bam_result' plot(x, ...)## S3 method for class 'bam_result' print(x, digits = 4L, ...) ## S3 method for class 'bam_result' summary(object, ...) ## S3 method for class 'summary.bam_result' print(x, ...) ## S3 method for class 'bam_result' format(x, ...) ## S3 method for class 'bam_result' as.data.table(x, keep.rownames = FALSE, ..., component = 1L) ## S3 method for class 'bam_result' as.data.frame(x, row.names = NULL, optional = FALSE, ..., component = 1L) ## S3 method for class 'bam_result' plot(x, ...)
x, object
|
a bayesammi result. |
digits |
significant digits of printed numbers (default 4). |
... |
passed on (to |
keep.rownames, row.names, optional
|
as in |
component |
name or number of the component to convert (default: the first one). |
print() returns x invisibly; summary() an object of class
summary.bam_result; format() a character string; as.data.table() and
as.data.frame() the chosen component as a table; plot() a ggplot object.
Muhammad Yaseen ([email protected])
bayes_ammi() estimates the additive main effects and multiplicative interaction (AMMI) model of a
multi-environment trial by the Gibbs sampler of Crossa et al. (2011), or the GGE (sites regression, SREG) model
of Perez-Elizalde et al. (2012), for balanced or unbalanced trials, with one error variance or one for every
environment. The sampler is compiled (C++). Every parameter (overall mean, genotype and
environment effects, singular values, genotype and environment scores of the bilinear terms, error variance) has a
posterior distribution, so that the biplot carries statistical inference: highest posterior density (HPD)
regions around the scores show which genotypes and environments interact significantly and which form
homogeneous groups (biplots).
bayes_ammi( .data, .y, .gen, .env, .rep, .nIter = 1000L, .k = 2L, .burnin = 0L, .thin = 1L, .chains = 1L, .priors = bam_priors(), .level = 0.95, .seed = NULL, .align = TRUE, .model = c("AMMI", "GGE"), .het = FALSE, .waic = TRUE ) ## Default S3 method: bayes_ammi( .data, .y, .gen, .env, .rep, .nIter = 1000L, .k = 2L, .burnin = 0L, .thin = 1L, .chains = 1L, .priors = bam_priors(), .level = 0.95, .seed = NULL, .align = TRUE, .model = c("AMMI", "GGE"), .het = FALSE, .waic = TRUE )bayes_ammi( .data, .y, .gen, .env, .rep, .nIter = 1000L, .k = 2L, .burnin = 0L, .thin = 1L, .chains = 1L, .priors = bam_priors(), .level = 0.95, .seed = NULL, .align = TRUE, .model = c("AMMI", "GGE"), .het = FALSE, .waic = TRUE ) ## Default S3 method: bayes_ammi( .data, .y, .gen, .env, .rep, .nIter = 1000L, .k = 2L, .burnin = 0L, .thin = 1L, .chains = 1L, .priors = bam_priors(), .level = 0.95, .seed = NULL, .align = TRUE, .model = c("AMMI", "GGE"), .het = FALSE, .waic = TRUE )
.data |
a data frame with one row per plot. |
.y, .gen, .env, .rep
|
the columns of the response, genotypes, environments and replicates: bare names, strings or vectors. |
.nIter |
number of iterations kept per chain before thinning (after the burn-in). |
.k |
number of bilinear terms |
.burnin |
number of iterations discarded at the start of every chain (default 0). |
.thin |
keep every |
.chains |
number of chains (default 1; two or more give the Gelman-Rubin diagnostic). |
.priors |
the priors, from |
.level |
probability of the HPD intervals (default 0.95). |
.seed |
integer seed for a reproducible run, or |
.align |
keep the sign of every bilinear term (see Signs; default |
.model |
|
.het |
|
.waic |
compute WAIC during sampling (default |
Model. The response of genotype in replicate of environment is
with , , and genotype and environment score vectors
, of unit length, orthogonal to
and to each other ( = .k). The priors are those of bam_priors().
Conditional distributions. With the table of cell means,
replicates, observations, the orthonormal contrasts
of matrix_k() () and , each iteration draws
the same for with , and for
von Mises-Fisher distributions on the unit sphere of the subspace orthogonal to and to the
other score vectors (Crossa et al. 2011, eq. 8-9), and finally
with SSW the within-cell sum of squares. The chains start at the least-squares AMMI fit (the first chain) or at dispersed values (the others).
A variance for every environment (.het = TRUE): with independent priors .
With weights the genotype effects keep a closed normal
conditional (precision ); the overall mean and the environment effects are drawn
jointly; has precision ; the
genotype scores stay von Mises-Fisher; the environment scores have the Bingham-von Mises-Fisher conditional
( with the cell
residual without term ), drawn by a Gibbs sweep in the eigenbasis of its quadratic term (Hoff 2009);
every is a scaled inverse chi-square with degrees of freedom.
GGE model (.model = "GGE"): : the genotype main effect is part of the
multiplicative terms, the genotype scores are orthogonal to , the environment scores only to
each other (Perez-Elizalde et al. 2012). The conditional distributions are those above without
and without the constraint .
Unbalanced trials. Missing plots and whole missing genotype-environment cells are completed by data
augmentation: with the largest number of replicates of a cell, every iteration first draws the missing
plots from , then the conditional distributions of the balanced
design apply exactly (the plots are assumed missing at random). Every genotype and every environment needs some
data.
Model choice. With .waic = TRUE the sampler accumulates the pointwise log-likelihood of the observed
plots, giving WAIC; the deviance of every kept draw gives DIC (component fit; bam_compare()).
Signs. The pair and its
negative give the same model. With .align = TRUE (default) every draw takes the sign that agrees with the
least-squares vectors, so that posterior means and HPD regions refer to one orientation of each axis; with
.align = FALSE a weak axis can switch sign during the run and its posterior means shrink towards zero.
Changes from the earlier versions. The singular values were computed once and never sampled; the error
variance was not returned (tau1 held the constant precision of the least-squares fit); the residuals for
were computed against the wrong environments; the within-cell sum of squares was a sum of
variances; the covariance matrices of the main effects were square roots of variances; the scores were not drawn
from their constrained conditional distributions; all axes were fitted.
tau1 now holds the draws of the error variance .
An object of class c("bam_bayes_ammi", "bam_result", "list"); the components of the earlier
versions come first, the draws of all chains one after the other:
mu1data.table, column mu: draws of the overall mean.
tau1data.table, column tau: draws of the error variance
(columns tau1, ..., tauE with a variance for every environment).
tao1data.table, columns tao1, ..., taoG: draws of the genotype effects (no
columns for the GGE model).
delta1data.table, columns delta1, ...: draws of the environment effects.
lambdas1data.table, columns lambdas1, ...: draws of the singular values.
alphas1, gammas1
matrices with columns .nIter (draw), Gen or Env
(number) and alphas1, ... or gammas1, ...: draws of the genotype and environment scores.
alphas0, gammas0
data.tables: least-squares scores (the starting values).
summarydata.table: posterior mean, standard deviation, Monte Carlo standard error, HPD
interval, effective sample size and potential scale reduction factor of every parameter (Tables 1 and B1
of Crossa et al. 2011).
scoresdata.table: posterior means of the biplot coordinates
and , with the mean of every genotype and environment.
drawscoda::mcmc.list of all parameters, one element per chain.
diagnosticslist: gelman (potential scale reduction factors, two or more chains),
raftery (Raftery-Lewis dependence factors), heidel (Heidelberger-Welch stationarity and
half-width tests), for the overall mean, the error variance, the main effects and the singular values.
lslist: the least-squares AMMI estimates (mu, tau, delta, lambda,
alpha, gamma, sigma2).
fitlist: deviance of every kept draw, Dbar, Dhat, pD, DIC,
and with .waic = TRUE lppd, p_waic, WAIC, waic_se and waic_i
(the contribution of every observed plot to WAIC, in the order of the data).
settingslist: iterations, burn-in, thinning, chains, number of terms, model, variances, priors (with the scale of the error variance filled in), level, seed, alignment, time used.
Methods: print(), summary(), plot() (which = c("trace", "density", "biplot",
"effects")), biplots(), bam_interpret(), the decision tools
(bam_predict(), bam_winners(), bam_superiority(),
bam_ranks(), bam_stability()), bam_compare(), bam_ppc() and
posterior::as_draws_df() (bam-draws).
Muhammad Yaseen ([email protected]), Jose Crossa ([email protected]), Sergio Perez-Elizalde ([email protected]), Diego Jarquin ([email protected]), Jose Miguel Cotes, Kert Viele, Genzhou Liu, Paul L. Cornelius
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. Crop Science, 51(4), 1458–1469. doi:10.2135/cropsci2010.06.0343
Viele, K. and Srinivasan, C. (2000). Parsimonious estimation of multiplicative interaction in analysis of variance using Kullback-Leibler information. Journal of Statistical Planning and Inference, 84(1–2), 201–219.
Perez-Elizalde, S., Jarquin, D. and Crossa, J. (2012). A general Bayesian estimation method of linear-bilinear models applied to plant breeding trials with genotype x environment interaction. Journal of Agricultural, Biological, and Environmental Statistics, 17, 15–37. doi:10.1007/s13253-011-0063-9
Hoff, P. D. (2009). Simulation of the matrix Bingham-von Mises-Fisher distribution, with applications to multivariate and relational data. Journal of Computational and Graphical Statistics, 18(2), 438–456. doi:10.1198/jcgs.2009.07177
Wood, A. T. A. (1994). Simulation of the von Mises Fisher distribution. Communications in Statistics - Simulation and Computation, 23(1), 157–164.
biplots, bam_priors, bam_interpret, ge_ammi
data(Maiz) fm1 <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 200 , .k = 2 , .burnin = 50 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) fm1 head(fm1$summary) fm1$fit$WAIC plot(x = fm1, which = "trace") plot(x = fm1, which = "biplot")data(Maiz) fm1 <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 200 , .k = 2 , .burnin = 50 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = "AMMI" , .het = FALSE , .waic = TRUE ) fm1 head(fm1$summary) fm1$fit$WAIC plot(x = fm1, which = "trace") plot(x = fm1, which = "biplot")
bayes_stability() fits by Gibbs sampling the joint regression models of Finlay and Wilkinson (1963) and
Eberhart and Russell (1966), and the heterogeneous interaction variance model of Shukla (1972), to the plots of a
multi-environment trial. Every stability parameter (slope, deviation variance, stability variance, safety-first
index) then has a posterior distribution, so genotypes can be compared by probabilities rather than by
significance tests. The data may be unbalanced: plots or whole genotype-environment cells may be missing.
bayes_stability( .data, .y, .gen, .env, .rep, .model = c("ER", "FW", "Shukla"), .nIter = 1000L, .burnin = 0L, .thin = 1L, .chains = 1L, .priors = bam_stab_priors(), .level = 0.95, .alpha = 0.05, .seed = NULL, .waic = TRUE )bayes_stability( .data, .y, .gen, .env, .rep, .model = c("ER", "FW", "Shukla"), .nIter = 1000L, .burnin = 0L, .thin = 1L, .chains = 1L, .priors = bam_stab_priors(), .level = 0.95, .alpha = 0.05, .seed = NULL, .waic = TRUE )
.data |
data frame with one row per plot. |
.y, .gen, .env, .rep
|
columns of the response, genotype, environment and replicate (bare names or strings). |
.model |
|
.nIter |
number of iterations kept per chain before thinning (default 1000). |
.burnin |
number of iterations discarded at the start of every chain (default 0). |
.thin |
keep every |
.chains |
number of chains (default 1); the first starts at the least-squares estimates, the others at dispersed values. |
.priors |
priors from |
.level |
probability of the highest posterior density intervals (default 0.95). |
.alpha |
probability of the safety-first index (default 0.05, as in Eskridge 1990). |
.seed |
seed of the random numbers (the random number state of the session is restored afterwards). |
.waic |
compute WAIC during sampling (default |
For genotype , environment and plot ,
with . The environment effects
are the environmental index, estimated jointly with the other parameters as in the Bayesian
Finlay-Wilkinson regression of Lian and de los Campos (2016) instead of being fixed at the environment means; the
slope of genotype is , with average 1.
"ER"Eberhart-Russell: slopes and a deviation variance for every
genotype (the Bayesian version of Oliveira et al. 2018). A stable genotype has a slope near 1 and a small
deviation variance.
"FW"Finlay-Wilkinson: slopes and one deviation variance for all genotypes.
"Shukla"no slopes () and an interaction variance
for every genotype: Shukla's stability variance, as in the Bayesian
heterogeneous variance model of Edwards and Jannink (2006).
The sampler draws the overall mean, the genotype effects, the environmental index and the slopes from their
normal conditional distributions with the deviations integrated out (each observed cell mean
then has variance ); then the deviations;
then the variances from their scaled inverse chi-squared conditionals. This partially collapsed Gibbs sampler
mixes well even when the deviations are large. Empty cells contribute no data; their deviations are drawn from the
prior, and bam_predict() predicts them.
stability reports, for every genotype, the posterior mean and HPD interval of its mean
, slope, deviation variance and the share of its variance across environments explained by
the regression,
with the variance of the environmental index; the posterior probability
that the slope exceeds 1; and the safety-first index of Eskridge (1990),
, with (Eberhart-Russell), (Finlay-Wilkinson) or (Shukla). When smaller
values are better (higher_better = FALSE in bam_interpret() and the decision functions), the
index is read the other way: , smaller better.
The result works with bam_predict(), bam_winners(), bam_superiority(),
bam_ranks(), bam_indices(), bam_compare() and
bam_ppc(), which use the draws of the cell means .
An object of class c("bam_bayes_stability", "bam_result", "list"):
stabilitydata.table, one row per genotype: Gen; mean, mean_lower,
mean_upper; slope, slope_lower, slope_upper, prob_slope_above_1;
dev_var, dev_var_lower, dev_var_upper; R2; safety_first,
safety_first_lower, safety_first_upper, prob_best_safety.
environmentsdata.table: Env, posterior mean and HPD interval of the environmental
index , and the observed environment mean.
summarydata.table of every parameter (mu, sigma2, g[i],
h[j], slope[i], sigma2_d[i]): posterior mean, sd, Monte Carlo error, HPD interval,
effective sample size, potential scale reduction factor.
drawscoda::mcmc.list of these parameters.
deviationsarray (draws x genotypes x environments) of the deviations .
diagnosticsGelman-Rubin, Raftery-Lewis and Heidelberger-Welch diagnostics of the overall mean, error variance, slopes and deviation variances.
fitDIC and WAIC, as in bayes_ammi().
lsleast-squares estimates (the start of the first chain).
settingsiterations, burn-in, thinning, chains, model, priors, level, alpha, seed, time used.
Methods: print(), plot(x, which = c("slopes", "lines", "deviations", "trace", "density")),
bam_interpret(), bam_cite().
Muhammad Yaseen ([email protected])
Finlay, K. W. and Wilkinson, G. N. (1963). The analysis of adaptation in a plant-breeding programme. Australian Journal of Agricultural Research, 14(6), 742–754. doi:10.1071/AR9630742
Eberhart, S. A. and Russell, W. A. (1966). Stability parameters for comparing varieties. Crop Science, 6(1), 36–40. doi:10.2135/cropsci1966.0011183X000600010011x
Shukla, G. K. (1972). Some statistical aspects of partitioning genotype-environmental components of variability. Heredity, 29(2), 237–245. doi:10.1038/hdy.1972.87
Eskridge, K. M. (1990). Selection of stable cultivars using a safety-first rule. Crop Science, 30, 369–374.
Edwards, J. W. and Jannink, J.-L. (2006). Bayesian modeling of heterogeneous error and genotype x environment interaction variances. Crop Science, 46(2), 820. doi:10.2135/cropsci2005.0164
Lian, L. and de los Campos, G. (2016). FW: an R package for Finlay-Wilkinson regression that incorporates genomic/pedigree information and covariance structures between environments. G3: Genes, Genomes, Genetics, 6(3), 589–597. doi:10.1534/g3.115.026328
Oliveira, T. R. A., Carvalho, H. W. L., Nascimento, M., Costa, E. F. N., Amaral Junior, A. T., Gravina, G. A. and Carvalho Filho, J. L. S. (2018). The Eberhart and Russell's Bayesian method used as an instrument to select maize hybrids. Euphytica, 214, 64. doi:10.1007/s10681-018-2146-y
bam_stab_priors, bam_indices, bayes_ammi
Other stability:
bam_ammi_indices(),
bam_indices(),
bam_stab_priors()
data(Maiz) fs <- bayes_stability( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .model = "ER" , .nIter = 1000 , .burnin = 200 , .thin = 1 , .chains = 1 , .priors = bam_stab_priors( mu_var = NULL , g_var = NULL , h_var = NULL , b_var = 100 , nu = 1 , s2 = NULL , nu_d = 1 , s2_d = NULL ) , .level = 0.95 , .alpha = 0.05 , .seed = 1 , .waic = TRUE ) fs plot(x = fs, which = "slopes")data(Maiz) fs <- bayes_stability( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .model = "ER" , .nIter = 1000 , .burnin = 200 , .thin = 1 , .chains = 1 , .priors = bam_stab_priors( mu_var = NULL , g_var = NULL , h_var = NULL , b_var = 100 , nu = 1 , s2 = NULL , nu_d = 1 , s2_d = NULL ) , .level = 0.95 , .alpha = 0.05 , .seed = 1 , .waic = TRUE ) fs plot(x = fs, which = "slopes")
biplots() draws the Bayesian AMMI biplot of the first two bilinear terms with a highest posterior density
(HPD) region around every genotype and environment (Crossa et al. 2011, Fig. 3 and 4). A region that contains the
origin marks a genotype or environment whose interaction is not different from zero (stable); regions that
overlap mark genotypes or environments that cannot be told apart, a homogeneous group.
biplots( model, burnin = 0.3, thin = 0.2, pb = 0.05, plot_stable = TRUE, plot_unstable = TRUE, ncolors = 5, .which = c("both", "genotype", "environment"), .grid = 100L ) ## Default S3 method: biplots( model, burnin = 0.3, thin = 0.2, pb = 0.05, plot_stable = TRUE, plot_unstable = TRUE, ncolors = 5, .which = c("both", "genotype", "environment"), .grid = 100L )biplots( model, burnin = 0.3, thin = 0.2, pb = 0.05, plot_stable = TRUE, plot_unstable = TRUE, ncolors = 5, .which = c("both", "genotype", "environment"), .grid = 100L ) ## Default S3 method: biplots( model, burnin = 0.3, thin = 0.2, pb = 0.05, plot_stable = TRUE, plot_unstable = TRUE, ncolors = 5, .which = c("both", "genotype", "environment"), .grid = 100L )
model |
the result of |
burnin |
proportion of the stored draws of every chain discarded at its start (default 0.3). |
thin |
proportion of the remaining draws used (default 0.2: every fifth draw). |
pb |
one or more probabilities |
plot_stable, plot_unstable
|
draw the regions that contain the origin, and those that do not (default both). |
ncolors |
number of colours used for the regions (default 5). |
.which |
|
.grid |
number of grid points per axis of the density estimate (default 100). |
The points are the biplot coordinates of the paper,
computed draw by draw. For each genotype and environment a bivariate kernel density is estimated
from the draws (normal kernels, normal reference bandwidths); the % HPD region is
with the
-quantile of at the draws, so that the region holds % of
them. The region contains the origin when (stable). The
criterion of the paper, the marginal HPD interval of the first coordinate excluding zero, is given as
axis1_significant.
Changes from the earlier versions. The regions were drawn for the singular vectors without the factor
, with a fixed bandwidth of 0.2 whatever the scale; a genotype counted as
stable when the bounding box of its contour covered the origin.
An object of class c("bam_biplots", "bam_result", "list"), with the components of the earlier
version:
contornsdata.table of the region boundaries: byplot (Genotype, Environment),
ID (number), name, prob (the region, for instance "95%"), piece (a region can have
several pieces), x, y, stable.
biplot_datadata.table, one row per genotype and environment: byplot, ID,
name, x, y (posterior means of the coordinates), stable (region contains the
origin), axis1_lower, axis1_upper (marginal HPD interval of the first coordinate),
axis1_significant (it excludes zero), group (sign of the first coordinate when significant:
positive, negative, or not significant).
biplotthe ggplot.
Methods: print(), plot(), bam_interpret().
Julian Garcia Abadillo Velasco ([email protected]), Diego Jarquin ([email protected]), Muhammad Yaseen ([email protected])
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. Crop Science, 51(4), 1458–1469. doi:10.2135/cropsci2010.06.0343
Hyndman, R. J. (1996). Computing and graphing highest density regions. The American Statistician, 50(2), 120–126.
data(Maiz) fm1 <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 1000 , .k = 2 , .burnin = 200 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = c("AMMI", "GGE") , .het = FALSE , .waic = TRUE ) bp <- biplots( model = fm1 , burnin = 0 , thin = 1 , pb = c(0.05, 0.01) , plot_stable = TRUE , plot_unstable = TRUE , ncolors = 5 , .which = "both" , .grid = 100 ) bp$biplot bp$biplot_datadata(Maiz) fm1 <- bayes_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep , .nIter = 1000 , .k = 2 , .burnin = 200 , .thin = 1 , .chains = 1 , .priors = bam_priors( mu_mean = 0 , mu_var = 1e+8 , tau_mean = 0 , tau_var = 1e+8 , delta_mean = 0 , delta_var = 1e+8 , lambda_mean = 0 , lambda_var = 1e+8 , nu = 1 , s2 = NULL ) , .level = 0.95 , .seed = 1 , .align = TRUE , .model = c("AMMI", "GGE") , .het = FALSE , .waic = TRUE ) bp <- biplots( model = fm1 , burnin = 0 , thin = 1 , pb = c(0.05, 0.01) , plot_stable = TRUE , plot_unstable = TRUE , ncolors = 5 , .which = "both" , .grid = 100 ) bp$biplot bp$biplot_data
e_eff() computes the environment main effects, the deviations of the environment means from the grand mean.
e_eff(.data, .y, .gen, .env) ## Default S3 method: e_eff(.data, .y, .gen, .env)e_eff(.data, .y, .gen, .env) ## Default S3 method: e_eff(.data, .y, .gen, .env)
.data |
a data frame with one row per plot. |
.y, .gen, .env
|
the columns of the response, genotypes and environments: bare names, strings or vectors. |
An matrix with column EEffs (row names: environments).
Muhammad Yaseen ([email protected])
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. \emphCrop Science, \strong51(4), 1458–1469. \doi10.2135/cropsci2010.06.0343
data(Maiz) e_eff( .data = Maiz , .y = y , .gen = entry , .env = site )data(Maiz) e_eff( .data = Maiz , .y = y , .gen = entry , .env = site )
g_eff() computes the genotype main effects, the deviations of the genotype means from the grand mean.
g_eff(.data, .y, .gen, .env) ## Default S3 method: g_eff(.data, .y, .gen, .env)g_eff(.data, .y, .gen, .env) ## Default S3 method: g_eff(.data, .y, .gen, .env)
.data |
a data frame with one row per plot. |
.y, .gen, .env
|
the columns of the response, genotypes and environments: bare names, strings or vectors. |
the least-squares estimates of the AMMI model (equal to the deviations of the plot means when the data are balanced).
A matrix with column GEffs (row names: genotypes).
Muhammad Yaseen ([email protected])
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. \emphCrop Science, \strong51(4), 1458–1469. \doi10.2135/cropsci2010.06.0343
data(Maiz) g_eff( .data = Maiz , .y = y , .gen = entry , .env = site )data(Maiz) g_eff( .data = Maiz , .y = y , .gen = entry , .env = site )
ge_ammi() computes the least-squares estimates of the AMMI model with all interaction axes: grand mean,
genotype and environment effects, singular values and vectors of the interaction, and the error variance. They
are the starting values of bayes_ammi() and the classical estimates it is compared with.
ge_ammi(.data, .y, .gen, .env, .rep) ## Default S3 method: ge_ammi(.data, .y, .gen, .env, .rep)ge_ammi(.data, .y, .gen, .env, .rep) ## Default S3 method: ge_ammi(.data, .y, .gen, .env, .rep)
.data |
a data frame with one row per plot. |
.y, .gen, .env, .rep
|
the columns of the response, genotypes, environments and replicates: bare names, strings or vectors. |
With the cell means of replicates, ,
, and the singular value decomposition of the interaction effects
(ge_eff()), axes. The error variance is the residual
variance of the model with random replicates within environments (ge_model()), in closed form for
balanced data:
when the replicate mean square is not smaller, otherwise (the replicate variance component estimated as zero)
; SSW is the within-cell and
the replicate-within-environment sum of squares.
Change from the earlier versions. The error variance came from lme4::lmer(); the closed form gives
the same value for balanced data without needing lme4.
A list (class c("bam_ge_ammi", "bam_result", "list")) with the components of the earlier versions:
g, e, Rep, k
numbers of genotypes, environments, replicates and axes.
ge_meansthe result of ge_mean().
mu, sigma2, tau
grand mean, error variance and its reciprocal (precision).
tao, delta
lambdas, alphas, gammas
singular values and genotype and environment singular vectors of the interaction.
Muhammad Yaseen ([email protected])
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. \emphCrop Science, \strong51(4), 1458–1469. \doi10.2135/cropsci2010.06.0343
Gauch, H. G. (1992). Statistical Analysis of Regional Yield Trials: AMMI Analysis of Factorial Designs. Elsevier, Amsterdam.
data(Maiz) fit <- ge_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep ) fit$lambdas fit$sigma2data(Maiz) fit <- ge_ammi( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep ) fit$lambdas fit$sigma2
ge_eff() computes the interaction effects (the cell means centred on genotype and environment means) and
their singular value decomposition, the least-squares estimate of the multiplicative part of the AMMI model.
ge_eff(.data, .y, .gen, .env) ## Default S3 method: ge_eff(.data, .y, .gen, .env)ge_eff(.data, .y, .gen, .env) ## Default S3 method: ge_eff(.data, .y, .gen, .env)
.data |
a data frame with one row per plot. |
.y, .gen, .env
|
the columns of the response, genotypes and environments: bare names, strings or vectors. |
with singular values and orthonormal
singular vectors orthogonal to .
A list (class c("bam_ge_eff", "bam_result", "list")) with ge_effects (the matrix ) and ge_svd (svd() of it: d, u, v).
Muhammad Yaseen ([email protected])
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. \emphCrop Science, \strong51(4), 1458–1469. \doi10.2135/cropsci2010.06.0343
Gauch, H. G. (1992). Statistical Analysis of Regional Yield Trials: AMMI Analysis of Factorial Designs. Elsevier, Amsterdam.
data(Maiz) fit <- ge_eff( .data = Maiz , .y = y , .gen = entry , .env = site ) fit$ge_svd$ddata(Maiz) fit <- ge_eff( .data = Maiz , .y = y , .gen = entry , .env = site ) fit$ge_svd$d
ge_mean() computes the table of genotype-by-environment cell means and the grand mean, the data of the
AMMI model.
ge_mean(.data, .y, .gen, .env) ## Default S3 method: ge_mean(.data, .y, .gen, .env)ge_mean(.data, .y, .gen, .env) ## Default S3 method: ge_mean(.data, .y, .gen, .env)
.data |
a data frame with one row per plot. |
.y, .gen, .env
|
the columns of the response, genotypes and environments: bare names, strings or vectors. |
With the response of genotype in replicate of environment
and the number of replicates of the cell,
Genotypes and environments are in the order of their factor levels (sorted values when the columns are not factors).
A list (class c("bam_ge_mean", "bam_result", "list")) with ge_means, the matrix of means (row and column names: genotypes and environments), and grand_mean.
Muhammad Yaseen ([email protected])
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. \emphCrop Science, \strong51(4), 1458–1469. \doi10.2135/cropsci2010.06.0343
data(Maiz) ge_mean( .data = Maiz , .y = y , .gen = entry , .env = site )data(Maiz) ge_mean( .data = Maiz , .y = y , .gen = entry , .env = site )
ge_model() fits the two-way model with interaction and random replicates within environments by restricted
maximum likelihood (lme4::lmer()). Its residual variance is the error variance of the least-squares AMMI
fit (ge_ammi(), which computes it in closed form).
ge_model(.data, .y, .gen, .env, .rep) ## Default S3 method: ge_model(.data, .y, .gen, .env, .rep)ge_model(.data, .y, .gen, .env, .rep) ## Default S3 method: ge_model(.data, .y, .gen, .env, .rep)
.data |
a data frame with one row per plot. |
.y, .gen, .env, .rep
|
the columns of the response, genotypes, environments and replicates: bare names, strings or vectors. |
The package lme4 is needed (it is suggested, not required, since version 1.0.0).
The lmerMod object of lme4::lmer(Y ~ Env + Gen + Env:Gen + (1 | Env:Rep)).
Muhammad Yaseen ([email protected])
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. \emphCrop Science, \strong51(4), 1458–1469. \doi10.2135/cropsci2010.06.0343
Bates, D., Maechler, M., Bolker, B. and Walker, S. (2015). Fitting linear mixed-effects models using lme4. Journal of Statistical Software, 67(1), 1–48. doi:10.18637/jss.v067.i01
data(Maiz) if (requireNamespace("lme4", quietly = TRUE)) { fm <- ge_model( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep ) stats::sigma(fm)^2 }data(Maiz) if (requireNamespace("lme4", quietly = TRUE)) { fm <- ge_model( .data = Maiz , .y = y , .gen = entry , .env = site , .rep = rep ) stats::sigma(fm)^2 }
ge_var() computes the variance of the replicates of every genotype-by-environment cell.
ge_var(.data, .y, .gen, .env) ## Default S3 method: ge_var(.data, .y, .gen, .env)ge_var(.data, .y, .gen, .env) ## Default S3 method: ge_var(.data, .y, .gen, .env)
.data |
a data frame with one row per plot. |
.y, .gen, .env
|
the columns of the response, genotypes and environments: bare names, strings or vectors. |
NA for a cell with one replicate. The within-cell sum of squares of the Bayesian AMMI model is
.
Change from the earlier versions. bayes_ammi() used the sum of these variances in place of the
within-cell sum of squares.
A list (class c("bam_ge_var", "bam_result", "list")) with ge_variances, the matrix of variances.
Muhammad Yaseen ([email protected])
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. \emphCrop Science, \strong51(4), 1458–1469. \doi10.2135/cropsci2010.06.0343
data(Maiz) ge_var( .data = Maiz , .y = y , .gen = entry , .env = site )data(Maiz) ge_var( .data = Maiz , .y = y , .gen = entry , .env = site )
Grain yield of 9 maize (Zea mays L.) genotypes in 20 sites, a randomized complete block design with 4 replicates in every site: the example of Crossa et al. (2011), also used by Burgueno et al. (2008).
MaizMaiz
A data.frame with 720 rows and 7 columns:
sitesite (environment), 1 to 20.
entrygenotype, 1 to 9.
fold10, fold5, fold3
fold numbers of 10-, 5- and 3-fold cross-validation (by genotype).
repreplicate within the site, 1 to 4.
ygrain yield (kg/ha).
The grand mean is 4858 kg/ha; the least-squares singular values of the interaction are 5923 and 3070 for the first two terms (Crossa et al. 2011).
Change from the earlier versions. The help page described another data set (1320 rows; columns Gen, Institute, Rep, Block, Env, Yield).
Muhammad Yaseen ([email protected]), Jose Crossa ([email protected])
International Maize and Wheat Improvement Center (CIMMYT).
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. Crop Science, 51(4), 1458–1469. doi:10.2135/cropsci2010.06.0343
Burgueno, J., Crossa, J., Cornelius, P. L. and Yang, R.-C. (2008). Using factor analytic models for joining environments and genotypes without crossover genotype x environment interaction. Crop Science, 48(4), 1291–1305.
data(Maiz) str(Maiz) ge_mean( .data = Maiz , .y = y , .gen = entry , .env = site )$grand_meandata(Maiz) str(Maiz) ge_mean( .data = Maiz , .y = y , .gen = entry , .env = site )$grand_mean
matrix_k() returns the matrix whose rows are
orthonormal and orthogonal to (Helmert contrasts). bayes_ammi() writes the
main effects as , which keeps them summing to
zero.
matrix_k(n) ## Default S3 method: matrix_k(n)matrix_k(n) ## Default S3 method: matrix_k(n)
n |
number of columns (at least 2). |
Row () has in its first
positions, in position and after it, with
, so that
The matrix .
Muhammad Yaseen ([email protected])
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. \emphCrop Science, \strong51(4), 1458–1469. \doi10.2135/cropsci2010.06.0343
K <- matrix_k( n = 4 ) K round(x = K %*% t(K), digits = 10)K <- matrix_k( n = 4 ) K round(x = K %*% t(K), digits = 10)
orthnorm() orthogonalises the columns of a matrix by the Gram-Schmidt process, optionally completes them to
a basis of the whole space and scales them to unit length.
orthnorm(u = NULL, basis = TRUE, norm = TRUE) ## Default S3 method: orthnorm(u = NULL, basis = TRUE, norm = TRUE)orthnorm(u = NULL, basis = TRUE, norm = TRUE) ## Default S3 method: orthnorm(u = NULL, basis = TRUE, norm = TRUE)
u |
a matrix (or vector) whose columns are orthogonalised. |
basis |
complete the columns to a basis of the whole space (default |
norm |
scale the columns to unit length (default |
For columns ,
each divided by its length when norm = TRUE. With basis = TRUE and fewer columns than rows, unit
vectors are added (those least explained by the given columns) to complete a basis.
The matrix of orthogonal (orthonormal with norm = TRUE) columns; NULL for u = NULL.
Muhammad Yaseen ([email protected])
Crossa, J., Perez-Elizalde, S., Jarquin, D., Cotes, J. M., Viele, K., Liu, G. and Cornelius, P. L. (2011). Bayesian estimation of the additive main effects and multiplicative interaction model. \emphCrop Science, \strong51(4), 1458–1469. \doi10.2135/cropsci2010.06.0343
V <- orthnorm( u = cbind(1, 1:4) , basis = TRUE , norm = TRUE ) round(x = crossprod(V), digits = 10)V <- orthnorm( u = cbind(1, 1:4) , basis = TRUE , norm = TRUE ) round(x = crossprod(V), digits = 10)