
Create a posterior prediction from a Stan fit object
Source:R/utils-stan.R
posterior_predict_stanfit.RdThis function does simulates from the posterior of a created stan model, therefore providing a fast and efficient way to project coefficients obtained from Bayesian models to new/novel contexts.
Usage
posterior_predict_stanfit(
obj,
form,
newdata,
type = "predictor",
family = NULL,
offset = NULL,
draws = NULL,
intercept = NULL,
link = NULL,
feature_names = NULL
)Arguments
- obj
A
"stanfit"object from rstan or a"CmdStanFit"object from cmdstanr.- form
A
formulaobject created for the DistributionModel.- newdata
A data.frame with new data to be used for prediction.
- type
A
characterof whether the linearpredictoror theresponseis to be summarized.- family
A
charactergiving the family for simulating linear response values (Default:NULL)- offset
A vector with an optionally specified offset.
- draws
numeric indicating whether a specific number of draws should be taken.
- intercept
Optional intercept parameter name or fixed numeric intercept.
- link
Optional inverse-link name. Supports
"log","logit","cloglog", and"identity".- feature_names
Optional ordered feature names matching the Stan beta vector.