posterior_predict.flexreg: Posterior Predictive Method for ”flexreg” objects

View source: R/posterior_predictive.R

posterior_predict.flexregR Documentation

Posterior Predictive Method for `flexreg` objects

Description

The function takes an object of class `flexreg` and generates values from the posterior predictive distribution.

Usage

## S3 method for class 'flexreg'
posterior_predict(model, newdata = NULL, n.new = NULL)

Arguments

model

an object of class `flexreg`, usually the result of flexreg or flexreg_binom functions.

newdata

an optional data.frame containing variables with which to predict. If omitted, the fitted values are used.

n.new

an optional vector containing the total number of trials with which to predict. It must be specified if newdata is not NULL and the flexreg object is the result of the flexreg_binom function (i.e., the fitted model is binomial, beta-binomial, or flexible beta-binomial). The vector must have the same length as nrow(newdata).

Details

The function generates values from the posterior predictive distribution, which is the distribution of a future outcome given the observed data. The posterior predictive distribution is computed for y in case of bounded continuous responses and for y/n in case of bounded discrete responses.

Value

An object of class `flexreg_postpred` containing a matrix with the simulated posterior predictions. Each column refers to a statistical unit to predict.

References

Ascari, R., Migliorati, S. (2021). A new regression model for overdispersed binomial data accounting for outliers and an excess of zeros. Statistics in Medicine, 40(17), 3895–3914. doi:10.1002/sim.9005

Di Brisco, A. M., Migliorati, S., Ongaro, A. (2020). Robustness against outliers: A new variance inflated regression model for proportions. Statistical Modelling, 20(3), 274–309. doi:10.1177/1471082X18821213

Gelman, A., Carlin, J. B., Stern, H. S., Rubin, D. B. (2014). Bayesian Data Analysis, 3th edition. Chapman and Hall/CRC. doi:10.1201/b16018

Migliorati, S., Di Brisco, A. M., Ongaro, A. (2018). A New Regression Model for Bounded Responses. Bayesian Analysis, 13(3), 845–872. doi:10.1214/17-BA1079

Examples

## Not run: 
data("Reading")
FB <- flexreg(accuracy.adj ~ iq, data = Reading, n.iter=1000)
pp <- posterior_predict(FB)
plot(pp)

## End(Not run)


FlexReg documentation built on Sept. 29, 2023, 9:06 a.m.