Learn R Programming

rstanarm (version 2.10.1)

posterior_linpred: Posterior distribution of the linear predictor

Description

Extract the posterior draws of the linear predictor, possibly transformed by the inverse-link function. This function is occasionally convenient, but it should be used sparingly. Inference and model checking should generally be carried out using the posterior predictive distribution (see posterior_predict).

Usage

posterior_linpred(object, transform = FALSE, newdata = NULL, re.form = NULL, ...)

Arguments

object
A fitted model object returned by one of the rstanarm modeling functions. See stanreg-objects.
transform
Should the linear predictor be transformed using the inverse-link function? The default is FALSE, in which case the untransformed linear predictor is returned.
newdata, re.form
Same as for posterior_predict.
...
Currently unused.

Value

A draws by nrow(newdata) matrix of simulations from the posterior distribution of the (possibly transformed) linear predictor.

See Also

posterior_predict to draw from the posterior predictive distribution of the outcome, which is almost always preferable.

Examples

Run this code
if (!exists("example_model")) example(example_model)

# linear predictor on log-odds scale
linpred <- posterior_linpred(example_model)
# probabilities
probs <- posterior_linpred(example_model, transform = TRUE)

# not conditioning on any group-level parameters
probs2 <- posterior_linpred(example_model, transform = TRUE, re.form = NA)

Run the code above in your browser using DataLab