Extracts outputs of the Bayesian model fitted
using bayes_met()
, and provides some diagnostics.
Usage
extr_outs(model, probs = c(0.025, 0.975), verbose = FALSE)
Arguments
- model
An object of class
stanfit
, obtained usingbayes_met()
- probs
A vector with two elements representing the probabilities (in decimal scale) that will be considered for computing the quantiles.
- verbose
A logical value. If
TRUE
, the function will indicate the completed steps. Defaults toFALSE
Value
The function returns an object of class extr
, which is a list with:
variances
: a data frame containing the variance components of the model effects, their standard deviation, naive standard error and highest posterior density interval.post
: a list with the posterior of the effects, and the data generated by the model.map
: a list with the maximum posterior values of each effectppcheck
: a matrix containing the p-values of maximum, minimum, median, mean and standard deviation; effective number of parameters, WAIC2 value, Rhat and effective sample size.
Details
More details about the usage of extr_outs
and other functions of
the ProbBreed
package can be found at https://saulo-chaves.github.io/ProbBreed_site/.
See also
rstan::stan_diag, ggplot2::ggplot, rstan::check_hmc_diagnostics, plot.extr
Examples
# \donttest{
mod = bayes_met(data = maize,
gen = "Hybrid",
loc = "Location",
repl = c("Rep","Block"),
trait = "GY",
reg = "Region",
year = NULL,
res.het = TRUE,
iter = 2000, cores = 2, chain = 4)
#> 454.84 seconds (Total)
#> Chain 1:
#> Warning: There were 1 divergent transitions after warmup. See
#> https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
#> to find out why this is a problem and how to eliminate them.
#> Warning: There were 2 chains where the estimated Bayesian Fraction of Missing Information was low. See
#> https://mc-stan.org/misc/warnings.html#bfmi-low
#> Warning: Examine the pairs() plot to diagnose sampling problems
#> Warning: The largest R-hat is 1.26, indicating chains have not mixed.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#r-hat
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#bulk-ess
#> Warning: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#tail-ess
outs = extr_outs(model = mod,
probs = c(0.05, 0.95),
verbose = TRUE)
#> -> Posterior effects extracted
#> -> Variances extracted
#> -> Maximum posterior values extracted
#> -> Posterior predictive checks computed
#> 1 of 4000 iterations ended with a divergence (0.025%).
#> Try increasing 'adapt_delta' to remove the divergences.
#> 0 of 4000 iterations saturated the maximum tree depth of 10.
#> E-BFMI indicated possible pathological behavior:
#> Chain 2: E-BFMI = 0.049
#> Chain 4: E-BFMI = 0.188
#> E-BFMI below 0.2 indicates you may need to reparameterize your model.
# }