R: Generic function and default method for Bayesian R-squared

bayes_R2 {rstantools} | R Documentation

## Generic function and default method for Bayesian R-squared

### Description

Generic function and default method for Bayesian version of R-squared for regression models. See `bayes_R2.stanreg` in the rstanarm package for an example of defining a method.

### Usage

    bayes_R2(object, ...)

    ## Default S3 method:
    bayes_R2(object, y, ...)

### Arguments

`object` | The object to use.
`...` | Arguments passed to methods. See the methods in the rstanarm package for examples.
`y` | For the default method, a vector of y values the same length as the number of columns in the matrix used as `object`.

### Value

`bayes_R2` methods should return a vector of length equal to the posterior sample size.

The default method just takes `object` to be a matrix of y-hat values (one column per observation, one row per posterior draw) and `y` to be a vector with length equal to `ncol(object)`.

### See Also

- The rstanarm package for example methods (CRAN, GitHub).

- The guidelines for developers of R packages interfacing with Stan, a copy of which can be found in the package vignettes. See `browseVignettes("rstantools")` or `vignette(package = "rstantools")`. The document is also available online at the rstantools page on the CRAN website.

[Package rstantools version 1.4.0 Index]