Skip to contents

Create reports for Bayesian models. The description of the parameters follows the Sequential Effect eXistence and sIgnificance Testing framework (see SEXIT documentation).

Usage

# S3 method for stanreg
report(x, ...)

Arguments

x

Object of class lm or glm.

...

Arguments passed to or from other methods.

Value

An object of class report().

Examples

# \donttest{
# Bayesian models
library(rstanarm)
#> Loading required package: Rcpp
#> This is rstanarm version 2.21.3
#> - See https://mc-stan.org/rstanarm/articles/priors for changes to default priors!
#> - Default priors may change, so it's safest to specify priors, even if equivalent to the defaults.
#> - For execution on a local, multicore CPU with excess RAM we recommend calling
#>   options(mc.cores = parallel::detectCores())
model <- suppressWarnings(stan_glm(mpg ~ qsec + wt, data = mtcars, refresh = 0, iter = 500))
r <- report(model)
r
#> We fitted a Bayesian linear model (estimated using MCMC sampling with 4 chains
#> of 500 iterations and a warmup of 250) to predict mpg with qsec and wt
#> (formula: mpg ~ qsec + wt). Priors over parameters were set as normal (mean =
#> 0.00, SD = 8.43) distributions. The model's explanatory power is substantial
#> (R2 = 0.81, 95% CI [0.70, 0.89], adj. R2 = 0.79). The model's intercept,
#> corresponding to qsec = 0 and wt = 0, is at 19.60 (95% CI [10.21, 30.22]).
#> Within this model:
#> 
#>   - The effect of qsec (Median = 0.95, 95% CI [0.40, 1.42]) has a 100.00%
#> probability of being positive (> 0), 99.30% of being significant (> 0.30), and
#> 0.10% of being large (> 1.81). The estimation successfully converged (Rhat =
#> 0.999) and the indices are reliable (ESS = 1243)
#>   - The effect of wt (Median = -5.03, 95% CI [-5.99, -4.05]) has a 100.00%
#> probability of being negative (< 0), 100.00% of being significant (< -0.30),
#> and 100.00% of being large (< -1.81). The estimation successfully converged
#> (Rhat = 0.998) and the indices are reliable (ESS = 1053)
#> 
#> Following the Sequential Effect eXistence and sIgnificance Testing (SEXIT)
#> framework, we report the median of the posterior distribution and its 95% CI
#> (Highest Density Interval), along the probability of direction (pd), the
#> probability of significance and the probability of being large. The thresholds
#> beyond which the effect is considered as significant (i.e., non-negligible) and
#> large are |0.30| and |1.81| (corresponding respectively to 0.05 and 0.30 of the
#> outcome's SD). Convergence and stability of the Bayesian sampling has been
#> assessed using R-hat, which should be below 1.01 (Vehtari et al., 2019), and
#> Effective Sample Size (ESS), which should be greater than 1000 (Burkner, 2017).
#> and We fitted a Bayesian linear model (estimated using MCMC sampling with 4
#> chains of 500 iterations and a warmup of 250) to predict mpg with qsec and wt
#> (formula: mpg ~ qsec + wt). Priors over parameters were set as normal (mean =
#> 0.00, SD = 15.40) distributions. The model's explanatory power is substantial
#> (R2 = 0.81, 95% CI [0.70, 0.89], adj. R2 = 0.79). The model's intercept,
#> corresponding to qsec = 0 and wt = 0, is at 19.60 (95% CI [10.21, 30.22]).
#> Within this model:
#> 
#>   - The effect of qsec (Median = 0.95, 95% CI [0.40, 1.42]) has a 100.00%
#> probability of being positive (> 0), 99.30% of being significant (> 0.30), and
#> 0.10% of being large (> 1.81). The estimation successfully converged (Rhat =
#> 0.999) and the indices are reliable (ESS = 1243)
#>   - The effect of wt (Median = -5.03, 95% CI [-5.99, -4.05]) has a 100.00%
#> probability of being negative (< 0), 100.00% of being significant (< -0.30),
#> and 100.00% of being large (< -1.81). The estimation successfully converged
#> (Rhat = 0.998) and the indices are reliable (ESS = 1053)
#> 
#> Following the Sequential Effect eXistence and sIgnificance Testing (SEXIT)
#> framework, we report the median of the posterior distribution and its 95% CI
#> (Highest Density Interval), along the probability of direction (pd), the
#> probability of significance and the probability of being large. The thresholds
#> beyond which the effect is considered as significant (i.e., non-negligible) and
#> large are |0.30| and |1.81| (corresponding respectively to 0.05 and 0.30 of the
#> outcome's SD). Convergence and stability of the Bayesian sampling has been
#> assessed using R-hat, which should be below 1.01 (Vehtari et al., 2019), and
#> Effective Sample Size (ESS), which should be greater than 1000 (Burkner, 2017).
summary(r)
#> We fitted a Bayesian linear model to predict mpg with qsec and wt. Priors over
#> parameters were set as normal (mean = 0.00, SD = 8.43) distributions. The
#> model's explanatory power is substantial (R2 = 0.81, adj. R2 = 0.79). The
#> model's intercept is at 19.60 (95% CI [10.21, 30.22]). Within this model:
#> 
#>   - The effect of qsec (Median = 0.95, 95% CI [0.40, 1.42]) has 100.00%, 99.30%
#> and 0.10% probability of being positive (> 0), significant (> 0.30) and large
#> (> 1.81)
#>   - The effect of wt (Median = -5.03, 95% CI [-5.99, -4.05]) has 100.00%, 100.00%
#> and 100.00% probability of being negative (< 0), significant (< -0.30) and
#> large (< -1.81) and We fitted a Bayesian linear model to predict mpg with qsec
#> and wt. Priors over parameters were set as normal (mean = 0.00, SD = 15.40)
#> distributions. The model's explanatory power is substantial (R2 = 0.81, adj. R2
#> = 0.79). The model's intercept is at 19.60 (95% CI [10.21, 30.22]). Within this
#> model:
#> 
#>   - The effect of qsec (Median = 0.95, 95% CI [0.40, 1.42]) has 100.00%, 99.30%
#> and 0.10% probability of being positive (> 0), significant (> 0.30) and large
#> (> 1.81)
#>   - The effect of wt (Median = -5.03, 95% CI [-5.99, -4.05]) has 100.00%, 100.00%
#> and 100.00% probability of being negative (< 0), significant (< -0.30) and
#> large (< -1.81)
as.data.frame(r)
#> Parameter   | Median |         95% CI |     pd |  Rhat |     ESS |                   Prior |    Fit
#> ---------------------------------------------------------------------------------------------------
#> (Intercept) |  19.60 | [10.21, 30.22] | 99.90% | 0.999 | 1119.00 | Normal (20.09 +- 15.07) |       
#> qsec        |   0.95 | [ 0.40,  1.42] |   100% | 0.999 | 1243.00 |   Normal (0.00 +- 8.43) |       
#> wt          |  -5.03 | [-5.99, -4.05] |   100% | 0.998 | 1053.00 |  Normal (0.00 +- 15.40) |       
#>             |        |                |        |       |         |                         |       
#> ELPD        |        |                |        |       |         |                         | -79.33
#> LOOIC       |        |                |        |       |         |                         | 158.66
#> WAIC        |        |                |        |       |         |                         | 158.04
#> R2          |        |                |        |       |         |                         |   0.81
#> R2 (adj.)   |        |                |        |       |         |                         |   0.79
#> Sigma       |        |                |        |       |         |                         |   2.66
# }