bayes_met {ProbBreed} | R Documentation |
Bayesian model for multi-environment trials
Description
This function runs a Bayesian model for analyzing data from
Multi-environment trials using rstan
, the R
interface to Stan
.
Usage
bayes_met(
data,
gen,
loc,
repl,
trait,
reg = NULL,
year = NULL,
res.het = FALSE,
iter = 2000,
cores = 2,
chains = 4,
pars = NA,
warmup = floor(iter/2),
thin = 1,
seed = sample.int(.Machine$integer.max, 1),
init = "random",
verbose = FALSE,
algorithm = c("NUTS", "HMC", "Fixed_param"),
control = NULL,
include = TRUE,
show_messages = TRUE,
...
)
Arguments
data |
A data frame containing the observations. |
gen , loc |
A string. The name of the
column that corresponds to the evaluated genotype and location, respectively. If
the environment is a combination of other factors (for instance, location-year),
the name of the column that contains this information must be attributed to |
repl |
A string, a vector, or |
trait |
A string. The name of the column that corresponds to the analysed variable. |
reg |
A string or NULL. If the data has information of regions,
|
year |
A string or NULL. If the data set has information of time-related
environmental factors (years, seasons...), |
res.het |
Logical, indicating if the model should consider heterogeneous
residual variances. Default is |
iter |
A positive integer specifying the number of iterations for each chain (including warmup). The default is 2000. |
cores |
Number of cores to use when executing the chains in parallel,
which defaults to 1 but we recommend setting the |
chains |
A positive integer specifying the number of Markov chains. The default is 4. |
pars |
A vector of character strings specifying parameters of interest.
The default is |
warmup |
A positive integer specifying the number of warmup (aka burnin)
iterations per chain. If step-size adaptation is on (which it is by default),
this also controls the number of iterations for which adaptation is run (and
hence these warmup samples should not be used for inference). The number of
warmup iterations should be smaller than |
thin |
A positive integer specifying the period for saving samples. The default is 1, which is usually the recommended value. |
seed |
The seed for random number generation. The default is generated
from 1 to the maximum integer supported by R on the machine. Even if
multiple chains are used, only one seed is needed, with other chains having
seeds derived from that of the first chain to avoid dependent samples.
When a seed is specified by a number, |
init |
Initial values specification. See the detailed documentation for
the init argument in |
verbose |
|
algorithm |
One of sampling algorithms that are implemented in Stan.
Current options are |
control |
A named |
include |
Logical scalar defaulting to |
show_messages |
Either a logical scalar (defaulting to |
... |
Additional arguments can be |
Details
More details about the usage of bayes_met
and other function of
the ProbBreed
package can be found at https://saulo-chaves.github.io/ProbBreed_site/.
Information on solutions to solve convergence or mixing issue can be found at
https://mc-stan.org/misc/warnings.html.
Value
An object of S4 class stanfit
representing
the fitted results. Slot mode
for this object
indicates if the sampling is done or not.
Methods
sampling
signature(object = "stanmodel")
Call a sampler (NUTS, HMC, or Fixed_param depending on parameters) to draw samples from the model defined by S4 classstanmodel
given the data, initial values, etc.
See Also
rstan::sampling()
, rstan::stan()
, rstan::stanfit()
Examples
mod = bayes_met(data = maize,
gen = "Hybrid",
loc = "Location",
repl = c("Rep", "Block"),
year = NULL,
reg = 'Region',
res.het = FALSE,
trait = 'GY',
iter = 6000, cores = 4, chains = 4)