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 useful, but it should be used sparingly. Inference and model checking should generally be carried out using the posterior predictive distribution (i.e., using posterior_predict).

Usage

1
2
3
4
5
posterior_linpred(object, ...)

## S3 method for class 'stanreg'
posterior_linpred(object, transform = FALSE,
  newdata = NULL, re.form = NULL, offset = NULL, XZ = FALSE, ...)

Arguments

object

A fitted model object returned by one of the rstanarm modeling functions. See stanreg-objects.

...

Currently ignored.

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, offset

Same as for posterior_predict.

XZ

If TRUE then instead of computing the linear predictor the design matrix X (or cbind(X,Z) for models with group-specific terms) constructed from newdata is returned. The default is FALSE.

Value

The default is to return a draws by nrow(newdata) matrix of simulations from the posterior distribution of the (possibly transformed) linear predictor. The exception is if the argument XZ is set to TRUE (see the XZ argument description above).

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
if (!exists("example_model")) example(example_model)
print(family(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)

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.