bys_app(
launch.browser = TRUE
)2026-11-09
\[ \newcommand{\vy}{\mathbf{y}} \newcommand{\vx}{\mathbf{x}} \newcommand{\vb}{\mathbf{b}} \newcommand{\ve}{\mathbf{e}} \newcommand{\vone}{\mathbf{1}} \newcommand{\vbeta}{\boldsymbol{\beta}} \newcommand{\vmu}{\boldsymbol{\mu}} \newcommand{\mX}{\mathbf{X}} \newcommand{\mZ}{\mathbf{Z}} \newcommand{\mV}{\mathbf{V}} \newcommand{\mI}{\mathbf{I}} \newcommand{\mJ}{\mathbf{J}} \newcommand{\mSigma}{\boldsymbol{\Sigma}} \newcommand{\mY}{\mathbf{Y}} \newcommand{\mK}{\mathbf{K}} \newcommand{\mH}{\mathbf{H}} \newcommand{\va}{\boldsymbol{\alpha}} \newcommand{\vg}{\boldsymbol{\gamma}} \newcommand{\vt}{\boldsymbol{\tau}} \newcommand{\vd}{\boldsymbol{\delta}} \newcommand{\vtheta}{\boldsymbol{\theta}} \newcommand{\vv}{\mathbf{v}} \newcommand{\E}{\mathrm{E}} \newcommand{\Var}{\mathrm{Var}} \newcommand{\Cov}{\mathrm{Cov}} \newcommand{\tr}{\operatorname{tr}} \]
bys_app() opens an application in the web browser that runs the analyses of the package without code: the trial, the earlier trial as prior, the Bayesian AMMI or SREG model, the biplot with HPD regions and a comparison of models. This vignette describes its pages and how it keeps its results reproducible.
bys_app(
launch.browser = TRUE
)The application needs the suggested packages shiny, bslib and DT. magick with WebP support is optional: with it the plots are sent to the browser as lossless WebP images, smaller than the same PNG.
isTRUE(tryCatch(requireNamespace("magick", quietly = TRUE) && isTRUE(magick::magick_config()$webp),
error = function(e) FALSE))[1] TRUE
TRUE means WebP is available; otherwise the application sends PNG images.
| Page | What it does |
|---|---|
| Home | what the application does and the order of the pages |
| Data | the cultivo2009 example or a CSV file with one row per plot; the response, genotype, environment and replicate columns; the earlier trial as prior: none, cultivo2008 or a CSV file with the same columns |
| Model | AMMI or SREG, number of terms (0 for all), weight of the earlier trial, iterations, burn-in, thinning, chains, seed and vague priors; then the summary, traces, densities, the biplot of posterior means and the main effects |
| Biplot | the biplot with HPD regions, for genotypes, environments or both |
| Model choice | DIC and WAIC of models with different numbers of terms, with the earlier trial and, on request, without it |
| References | the articles behind the methods, as bys_cite() prints them |
Every result page has the same tabs:
bys_interpret(), with a button that copies it.The model page has a further tab, R code, with the code that reproduces the fit outside the application.
The model page after a fit of cultivo2009 with cultivo2008 as prior and two terms:
The biplot page of the same fit:
For the settings of the screenshots, the R code tab shows:
settings <-
list(
.y = "y"
, .gen = "entry"
, .env = "site"
, .rep = "rep"
, .nIter = 3000
, .n0 = NULL
, .model = "AMMI"
, .k = 2
, .burnin = 1000
, .thin = 1
, .chains = 2
, .priors = bys_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
)
cat(baystability:::.bys_app_code(a = settings, source = "cultivo", prior_source = "cultivo"))library(baystability)
data(cultivo2009)
data(cultivo2008)
fit <-
bayes_ammi(
.data = cultivo2009
, .y = y
, .gen = entry
, .env = site
, .rep = rep
, .nIter = 3000
, .prior_data = cultivo2008
, .n0 = NULL
, .model = "AMMI"
, .k = 2
, .burnin = 1000
, .thin = 1
, .chains = 2
, .priors = bys_priors(lambda_var = 1e+08, nu = 1)
, .level = 0.95
, .seed = 1
, .align = TRUE
, .waic = TRUE
)
fit
bys_interpret(
x = fit
, higher_better = TRUE
, top = 5
)
The seed fixes the draws, so the code returns the same numbers as the application.
bys_app_object() returns the application object without running it, for a server:
# app.R on a Shiny server
baystability::bys_app_object()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(1), 15–37. doi:10.1007/s13253-011-0063-9