R/posterior_predict.R
posterior_predict.Rd
Compute outcome predictions using posterior samples. Exposure data for prediction can be either original data used for model fit or new data.
A stanemax
class object
An optional data frame that contains columns needed for model to run (exposure and covariates). If the model does not have any covariate, this can be a numeric vector corresponding to the exposure metric.
An optional string specifying the type of return object.
An optional string specifying the type of newdata input, whether in the format of an original data frame or a processed model frame. Mostly used for internal purposes and users can usually leave at default.
Additional arguments passed to methods.
Credible interval of the response without residual variability.
Prediction interval of the response with residual variability.
An object that contain predicted response with posterior distribution of parameters. The default is a matrix containing predicted response. Each row of the matrix is a vector of predictions generated using a single draw of the model parameters from the posterior distribution.
If either dataframe
or tibble
is specified, the function returns a data frame or tibble object in a long format -
each row is a prediction generated using a single draw of the model parameters and a corresponding exposure.
Two types of predictions are generated with this function.
respHat
corresponds to the prediction without considering residual variability and is intended to provide credible interval of "mean" response.
response
include residual variability in its calculation, therefore the range represents prediction interval of observed response.
The return object also contains exposure and parameter values used for calculation.
With posterior_predict_quantile()
function, you can obtain quantiles
of respHat
and response
as specified by ci
and pi
.
Run vignette("emaxmodel", package = "rstanemax")
to see
how you can use the posterior prediction for plotting estimated Emax curve.