See predictive_interval.stanreg() in the rstanarm package for an example.

```
predictive_interval(object, ...)
# S3 method for default
predictive_interval(object, prob = 0.9, ...)
```

- object
The object to use.

- ...
Arguments passed to methods. See the methods in the rstanarm package for examples.

- prob
A number \(p \in (0,1)\) indicating the desired probability mass to include in the intervals.

`predictive_interval()`

methods should return a matrix with two
columns and as many rows as data points being predicted. For a given value
of `prob`

, \(p\), the columns correspond to the lower and upper
\(100p\)\

\(100(1 - \alpha/2)\)\

`prob=0.9`

is specified (a \(90\)\

would be `"5%"`

and `"95%"`

, respectively.

The default method just takes `object`

to be a matrix and computes
quantiles, with `prob`

defaulting to `0.9`

.

The rstanarm package (mc-stan.org/rstanarm) for example methods (CRAN, GitHub).

Guidelines and recommendations for developers of R packages interfacing with Stan and a demonstration getting a simple package working can be found in the vignettes included with rstantools and at mc-stan.org/rstantools/articles.

```
# Default method takes a numeric matrix (of draws from posterior
# predictive distribution)
ytilde <- matrix(rnorm(100 * 5, sd = 2), 100, 5) # fake draws
predictive_interval(ytilde, prob = 0.8)
#> 10% 90%
#> [1,] -2.544390 2.328161
#> [2,] -2.490438 2.792269
#> [3,] -2.740283 2.702532
#> [4,] -3.077965 2.483094
#> [5,] -2.264030 2.620028
# Also see help("predictive_interval", package = "rstanarm")
```