Description Usage Arguments Value References Examples

Compute a Bayesian version of R-squared or LOO-adjusted R-squared for regression models.

1 2 3 4 5 |

`object` |
A fitted model object returned by one of the
rstanarm modeling functions. See |

`...` |
Currently ignored. |

`re.form` |
For models with group-level terms, |

A vector of R-squared values with length equal to the posterior sample size (the posterior distribution of R-squared).

Andrew Gelman, Ben Goodrich, Jonah Gabry, and Aki Vehtari (2018). R-squared
for Bayesian regression models. *The American Statistician*, to appear.
DOI: 10.1080/00031305.2018.1549100.
(Journal,
Preprint,
Notebook)

1 2 3 4 5 6 7 8 9 10 11 12 13 | ```
fit <- stan_glm(mpg ~ wt + cyl, data = mtcars, QR = TRUE, chains = 2)
rsq <- bayes_R2(fit)
print(median(rsq))
hist(rsq)
loo_rsq <- loo_R2(fit)
print(median(loo_rsq))
# multilevel binomial model
if (!exists("example_model")) example(example_model)
print(example_model)
median(bayes_R2(example_model))
median(bayes_R2(example_model, re.form = NA)) # exclude group-level
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.