Learn R Programming

hsstan (version 0.8.2)

bayes_R2.hsstan: Bayesian and LOO-adjusted R-squared

Description

Compute the Bayesian and the LOO-adjusted R-squared from the posterior samples. For Bayesian R-squared it uses the modelled residual variance (rather than the variance of the posterior distribution of the residuals). The LOO-adjusted R-squared uses Pareto smoothed importance sampling LOO residuals and Bayesian bootstrap.

Usage

# S3 method for hsstan
bayes_R2(object, prob = 0.95, summary = TRUE, ...)

# S3 method for hsstan loo_R2(object, prob = 0.95, summary = TRUE, ...)

Value

The mean, standard deviation and posterior interval of R-squared if summary=TRUE, or a vector of R-squared values with length equal to the size of the posterior sample if summary=FALSE.

Arguments

object

An object of class hsstan.

prob

Width of the posterior interval (0.95, by default). It is ignored if summary=FALSE.

summary

Whether a summary of the distribution of the R-squared should be returned rather than the pointwise values (TRUE by default).

...

Currently ignored.

References

Andrew Gelman, Ben Goodrich, Jonah Gabry and Aki Vehtari (2019), R-squared for Bayesian regression models, The American Statistician, 73 (3), 307-309. tools:::Rd_expr_doi("10.1080/00031305.2018.1549100")

Aki Vehtari, Andrew Gelman, Ben Goodrich and Jonah Gabry (2019), Bayesian R2 and LOO-R2. https://avehtari.github.io/bayes_R2/bayes_R2.html

Examples

Run this code
utils::example("hsstan", echo=FALSE)
oldopts <- options(mc.cores=2)
# continued from ?hsstan
bayes_R2(hs.biom)
loo_R2(hs.biom)
options(oldopts)

Run the code above in your browser using DataLab